is there any way, how to finish certain activity from a stack? I have service, which looks for updates, and when update is found, it opens update activity, where prompt for installation will appears. But after the installation appears I want to finish update activity, because it is not necessary to still be on a stack.
Thanks
Try this please.
In first activity, define this before onCreate.
Then, in onCreate of first activity, write this.
Then, in second activity, write this when you want finish first one.
This will destroy first activity and when you press back on second activity, you will go back to home directly.
If the update activity is launching another installation activity, then you may want to override
void onActivityResult(int requestCode, int resultCode, Intent intent)
in the update activity, providing the following implementation. Also, when the update activity launches the installation activity, it should do so withstartActivityForResult(Intent, int)
, not withstartActivity(Intent)
.very helpful code
Use finish() method of the activity class to finish certain activity
Hope this will help you.
When your "update activity" calls
startActivity()
to bring up "the installation", have it immediately callfinish()
on itself.