I'm developing a custom launcher for android based signage (using MiniPC not a device), and follow this thread -> uninstall app silently with system priveleges to enable silent uninstall of 3rd party APK, which is required to do remote install & uninstall by our signage admin.
My implementation that follows the code from the above thread is like below
private class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
@Override
public void packageDeleted(String packageName, int returnCode) throws RemoteException {
}
}
//.... other codes ... //
@Override
protected void onHandleIntent(Intent intent) {
//.... other codes ... //
for (int x = 0; x < compliances.size(); x++) {
deleteObserver = new PackageDeleteObserver();
packageManager = getPackageManager();
Class<?>[] uninstalltypes = new Class[] {String.class, IPackageDeleteObserver.class, int.class};
Method uninstallMethod = packageManager.getClass().getMethod("deletePackage", uninstalltypes);
AppShortcut asc = compliances.get(x);
if (existing.contains(asc) && !asc.isInstalled()) {
uninstallMethod.invoke(packageManager, new Object[] {asc.getName(), deleteObserver, 0});
}
}
}
While my manifest with error signs on permission is like below
But I ignore those error signs, and using Genymotion emulator I ran it and I got below error in logcat
Please if anybody had made this works help me...