Reputation: 627
In my second activity, I can uninstall an app after uninstall finished, the second activity remains. But I need to go for previous activity after uninstall finished
Uri packageURI = Uri.parse("package:"+packageInfo.packageName);
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);
Upvotes: 0
Views: 1259
Reputation: 10136
Update your first activity (FirstActivity.java)
FirstActivity.java
Use startActivityForResult(uninstallIntent, 1); //1 is REQUEST_CODE
After unintalling app, FirstActivity.onActivityResult will be automatically called, you can use this method to do something.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
// un-installed successfully
finish();
}
else {
// failed to un-install
}
}
}
Upvotes: 4