Reputation: 1467
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
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