Note that there are some explanatory texts on larger screens.

plurals
  1. POuninstall app silently with system privileges
    primarykey
    data
    text
    <p>My app have system privileges. It will be inside firmware, now it's located at /system/app</p> <p>I was able to install apps silently with this post </p> <p><a href="https://stackoverflow.com/questions/6813322/install-uninstall-apks-programmatically-packagemanager-vs-intents">install / uninstall APKs programmatically (PackageManager vs Intents)</a></p> <p><strong>example app that works</strong></p> <p><a href="http://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/" rel="nofollow noreferrer">http://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/</a></p> <p>But I still can't uninstall apps the same way. I tried to use reflection like as in the installation example.</p> <pre><code>public ApplicationManager(Context context) throws SecurityException, NoSuchMethodException { observer = new PackageInstallObserver(); pm = context.getPackageManager(); Class&lt;?&gt;[] types = new Class[] {Uri.class, IPackageInstallObserver.class, int.class, String.class}; Class&lt;?&gt;[] uninstalltypes = new Class[] {String.class, IPackageInstallObserver.class, int.class}; method = pm.getClass().getMethod("installPackage", types); uninstallmethod = pm.getClass().getMethod("deletePackage", uninstalltypes); } public void uninstallPackage(String packagename) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { uninstallmethod.invoke(pm, new Object[] {packagename, observer, 0}); } public void installPackage(Uri apkFile) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { method.invoke(pm, new Object[] {apkFile, observer, INSTALL_REPLACE_EXISTING, null}); } </code></pre> <p>I have added uninstallPackage method and edited ApplicationManager method. Still cant get this working.</p> <p>When I run it I get method not found (on the invoke "deletePackage" line).</p> <p><strong>Here is not working project with my changes:</strong> <a href="https://dl.dropbox.com/u/1928109/InstallInBackgroundSample.zip" rel="nofollow noreferrer">https://dl.dropbox.com/u/1928109/InstallInBackgroundSample.zip</a></p> <p>Here is an description of function: <a href="http://www.androidjavadoc.com/1.0_r1_src/android/content/pm/PackageManager.html#deletePackage(java.lang.String" rel="nofollow noreferrer">http://www.androidjavadoc.com/1.0_r1_src/android/content/pm/PackageManager.html#deletePackage(java.lang.String</a>, android.content.pm.IPackageDeleteObserver, int)</p> <p>Parameters are ok. Seems like I should specify DeletePackageObserver class instead of InstallPackageObserver. But I don't know how to do that (I don't have such class).</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload