000000000000000000000
000000000000000000000

Reputation: 1467

Crash on android app uninstall via Intent

why does my app crash when I try to call this function?

public void uninstall(){
    Intent intent;
    String packageName;

    packageName = HelloWorldActivity.class.getPackage().getName();
    intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse(packageName));
    startActivity(intent);      
}

Do I need any permissions to uninstall packages?
Do I need to add .toString() to .getName()?

Upvotes: 3

Views: 102

Answers (1)

endasan
endasan

Reputation: 712

The Uri scheme for packages needs to have "package" keyword before the actual package name, so try this: packageName = "package:"+HelloWorldActivity.class.getPackage().getName();

Upvotes: 3

Related Questions