uninstall App by package name - Android App

Android examples for App:App Install

Description

uninstall App by package name

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.Intent;

import android.net.Uri;

public class Main {

    public static boolean uninstallApp(Context context, String packageName) {
        boolean success = false;
        final Uri uri = Uri.fromParts("package", packageName, null);
        final Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, uri);
        try {//  ww w.jav a  2  s  . co m
            context.startActivity(uninstallIntent);
            success = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success;
    }
}

Related Tutorials