Uninstall apps silently

Put your problem here if it does not fit any of the other categories.

Uninstall apps silently

Postby POMATu » Wed Jun 06, 2012 5:58 pm

My app have system priveleges. It will be inside firmware, now it's located at /system/app
I was able to install apps silently with this post
http://stackoverflow.com/questions/6813 ... vs-intents

example app that works
http://paulononaka.wordpress.com/2011/0 ... n-android/

But I still can't uninstall apps the same way. I tried to use reflecion like as in the installation example.

Code: Select all
public ApplicationManager(Context context) throws SecurityException, NoSuchMethodException {

    observer = new PackageInstallObserver();
    pm = context.getPackageManager();

    Class<?>[] types = new Class[] {Uri.class, IPackageInstallObserver.class, int.class, String.class};
    Class<?>[] 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});

I have added uninstallPackage method and edited ApplicationManager method. Still cant get this working.
Posts: 2
Joined: Tue Apr 12, 2011 5:39 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests