Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

how to uninstall app from android phone programmatically

public boolean uninstallPackage(Context context, String packageName) {
    ComponentName name = new ComponentName(MyAppName, MyDeviceAdminReceiver.class.getCanonicalName());
    PackageManager packageManger = context.getPackageManager();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        PackageInstaller packageInstaller = packageManger.getPackageInstaller();
        PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(
                PackageInstaller.SessionParams.MODE_FULL_INSTALL);
        params.setAppPackageName(packageName);
        int sessionId = 0;
        try {
            sessionId = packageInstaller.createSession(params);
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        packageInstaller.uninstall(packageName, PendingIntent.getBroadcast(context, sessionId,
                new Intent("android.intent.action.MAIN"), 0).getIntentSender());
        return true;
    }
    System.err.println("old sdk");
    return false;
}
Comment

PREVIOUS NEXT
Code Example
Shell :: bash add default argument 
Shell :: composer install -- 
Shell :: turtlebot installation 
Shell :: Update CA Certificate Linux 
Shell :: vim colorscheme 
Shell :: powershell delete all files wit hextension 
Shell :: mqtt client ubuntu console 
Shell :: sharepoint logs folder 
Shell :: Unable to connect to server: connection to server at "localhost" (127.0.0.1), port 5432 failed 
Shell :: bitnami wordpress enable ssh 
Shell :: git undo 
Shell :: update cordov ios 
Shell :: open folder in terminal mac 
Shell :: linux time now command 
Shell :: git merge without delete files 
Shell :: Install the postgres CLI tools 
Shell :: how to scan for raspberry pi on network windows 
Shell :: kubectl create 
Shell :: git clone and create directory 
Shell :: create self signed certificate 
Shell :: git make new branch 
Shell :: npm install react-navigation-stack 
Shell :: rmdir multiple directories 
Shell :: how to use yes command in linux 
Shell :: kubectl logs with grep 
Shell :: install font in react native 
Shell :: develop - FETCH_HEAD instead of origin develop 
Shell :: scp all files in currrent directory 
Shell :: letsencrypt error 
Shell :: chmod command 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =