Unistall Android Application Programmatically
I want to be able to allow my users to uninstall application from my application. Just like what Google Play Store allow to their users(Please below image) the main question is th
Solution 1:
try
Intentintent=newIntent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:app package name"));
startActivity(intent);
If this doesn't work then change intent to:
Intent.ACTION_UNINSTALL_PACKAGE);
and set datatype as:
intent.setDataAndType(Uri.parse("package:" + your app package name));
Solution 2:
Try this:
Intentintent=null;
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
intent = newIntent(Intent.ACTION_UNINSTALL_PACKAGE);
} else {
intent = newIntent(Intent.ACTION_DELETE);
}
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.fromParts("package", packageName, null));
if(intent.resolveActivity(getActivity( ).getPackageManager()) != null) {
startActivity(intent);
}
Solution 3:
kotlin // This is for kotlin
< uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
Code
val intent = Intent(Intent.ACTION_DELETE)
intent.data = Uri.parse("package:"+app_package_name)
startActivity(intent)
// note app package name should be given properly.
Post a Comment for "Unistall Android Application Programmatically"