crashes when uninstalling Android applications via intent… here is a solution to the problem.
crashes when uninstalling Android applications 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()
?
Solution
The package URI scheme requires the “package” keyword before the actual package name, so try this:
packageName = "package:"+HelloWorldActivity.class.getPackage().getName();