0

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.

Phil
  • 1
  • 1
  • can you just please explain your problem clearly dear ? – Quick learner Sep 06 '18 at 12:00
  • Possible duplicate of [Start app at a specific time](https://stackoverflow.com/questions/4452565/start-app-at-a-specific-time) – Torben Sep 06 '18 at 12:03
  • Basically, I would like my app to resume after a countdowntimer has finished even when in another app. I have used code as shown, which starts my app as a new instance even when i'm using another app, but i dont want a new instance, I want my app to resume. I then added the code shown to the manifest file, which does resume my app if i'm on the home screen, but does nothing if i'm looking at another app – Phil Sep 06 '18 at 12:06
  • Thanks Torban, I have looked at this link, but am not using alarm manager and doesn't seem to be anything like what I am trying to do. If I have not explained myself correctly, please let me know which part is misunderstood so that I cant try to make clearer. Thanks Phil – Phil Sep 07 '18 at 07:41

0 Answers0