I use the following code:
try { Class[] classMethods = new Class[2]; classMethods[0] = Long.TYPE; classMethods[1] = IPackageDataObserver.class; Method localMethod = pm.getClass().getMethod("freeStorageAndNotify", classMethods); Object[] classParams = new Object[2]; classParams[0] = Long.valueOf(getEnvironmentSize() - 1L); classParams[1] = new IPackageDataObserver.Stub() { public void onRemoveCompleted(String paramAnonymousString, boolean paramAnonymousBoolean) throws RemoteException { } }; localMethod.invoke(pm, classParams); } catch (Exception localException) { while (true) localException.printStackTrace(); }
IPackageDataObserver.aidl and<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
available
Ideas why not work? By the way, I checked similar applications. Everything works fine with this method.