你试下下面的能不能用:(因为hide了,文档中查不到的) /** * Attempts to move package resources from internal to external media or vice versa. * Since this may take a little while, the result will * be posted back to the given observer. This call may fail if the calling context * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the * named package cannot be found, or if the named package is a "system package". * * @param packageName The name of the package to delete * @param observer An observer callback to get notified when the package move is * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be * called when that happens. observer may be null to indicate that no callback is desired. * @param flags To indicate install location {@link #MOVE_INTERNAL} or * {@link #MOVE_EXTERNAL_MEDIA} * * @hide */ public abstract void movePackage( String packageName, IPackageMoveObserver observer, int flags); 参考代码: import android.content.pm.IPackageMoveObserver; import android.content.pm.PackageManager; class PackageMoveObserver extends IPackageMoveObserver.Stub { public void packageMoved(String packageName, int returnCode) throws RemoteException { //callback process } } private PackageManager mPm; private PackageMoveObserver mPackageMoveObserver; mPm = getActivity().getPackageManager(); mPackageMoveObserver = new PackageMoveObserver(); mPm.movePackage(mAppEntry.info.packageName, mPackageMoveObserver, moveFlags);如果不能的话,就只能自己来实现这个接口了,参考源码中Settings和PackageManagerService.movePackage()函数
/**
* Attempts to move package resources from internal to external media or vice versa.
* Since this may take a little while, the result will
* be posted back to the given observer. This call may fail if the calling context
* lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
* named package cannot be found, or if the named package is a "system package".
*
* @param packageName The name of the package to delete
* @param observer An observer callback to get notified when the package move is
* complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
* called when that happens. observer may be null to indicate that no callback is desired.
* @param flags To indicate install location {@link #MOVE_INTERNAL} or
* {@link #MOVE_EXTERNAL_MEDIA}
*
* @hide
*/
public abstract void movePackage(
String packageName, IPackageMoveObserver observer, int flags);
参考代码:
import android.content.pm.IPackageMoveObserver;
import android.content.pm.PackageManager; class PackageMoveObserver extends IPackageMoveObserver.Stub {
public void packageMoved(String packageName, int returnCode) throws RemoteException {
//callback process
}
} private PackageManager mPm;
private PackageMoveObserver mPackageMoveObserver;
mPm = getActivity().getPackageManager(); mPackageMoveObserver = new PackageMoveObserver();
mPm.movePackage(mAppEntry.info.packageName, mPackageMoveObserver, moveFlags);如果不能的话,就只能自己来实现这个接口了,参考源码中Settings和PackageManagerService.movePackage()函数