I have an app that I would like to resume after a specific event. Even if I'm in another app e.g. Google I have searched many answers and have found and implemented the following code:
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
The code above opens my app after the given event even when I am looking at another app eg google. But it opens as a second app, not as a resume of my original. So I found another bit of code which I inserted in my manifest file which was surposed to solve my problem, shown below.
<activity android:name="com.example.MainActivity">
android:launchMode="singleTask">
The above code helped in that my app will resume if on "home" page after a given event, but will not resume if I am looking at another app eg google.