我想從設備中靜默刪除應用程序。 我想這個代碼,但給出異常「既不是用戶10051也不是當前進程有android.permission.DELETE_PACKAGES。」在android中默默卸載應用程序?
class PackageInstallObserver extends IPackageInstallObserver.Stub {
public void packageInstalled(String packageName, int returnCode) throws RemoteException {
if (onInstalledPackaged != null) {
onInstalledPackaged.packageInstalled(packageName, returnCode);
}
}
}
class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
public void packageDeleted(String packageName, int returnCode) throws RemoteException {
/*if (onInstalledPackaged != null) {
onInstalledPackaged.packageInstalled(packageName, returnCode);
}*/
}
}
public ApplicationManager(Context context) throws SecurityException, NoSuchMethodException {
observer = new PackageInstallObserver();
observerdelete = new PackageDeleteObserver();
pm = context.getPackageManager();
Class<?>[] types = new Class[] {Uri.class, IPackageInstallObserver.class, int.class, String.class};
Class<?>[] uninstalltypes = new Class[] {String.class, IPackageDeleteObserver.class, int.class};
method = pm.getClass().getMethod("installPackage", types);
uninstallmethod = pm.getClass().getMethod("deletePackage", uninstalltypes);
}
public void setOnInstalledPackaged(OnInstalledPackaged onInstalledPackaged) {
this.onInstalledPackaged = onInstalledPackaged;
}
public void uninstallPackage(String packagename) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
uninstallmethod.invoke(pm, new Object[] {packagename, observerdelete, 0});
}
怎麼樣,而不需要「批量卸載程序」的工作應用服務,系統應用程序嗎?他們是否實際上做了uninsalling所需的相同操作,而不是使用「adb uninstall」? – 2013-03-21 20:30:57
這是從那裏玩商店頁面「只有ROOT電話或ROOT權利的電話可以執行靜音卸載,不會彈出任何對話框,並且不需要重複確認。只需一次觸摸批量卸載。沒有ROOT的電話將需要在系統界面中重複選擇「。 https://play.google.com/store/apps/details?id=cn.menue.BatchUninstall&hl=zh-CN – 2013-03-22 05:05:00
所以,當我說固件編譯它意味着應用程序與根.... – 2013-03-22 05:05:39