What I did was start the action using startActivityForResult (), and then when I want to end the application, set the result and complete (). Later I got this result:
public void onActivityResult (int requestCode, int resultCode, Intent data) {...}
And if I get the expected result, complete this step by setting a new result for the previous one.
This works for me, but itβs easy because I only have two previous actions in my case ...
source share