0

I have two activities. The first activity is running in the foreground. While pressing the home button, the first activity goes to the background and calls the service from there second activity is started using intent. Now the first activity is shown on top. I want to hide both of the activities in the background.

Starting the second Activity:

 Intent intent1 = new Intent(XXX.this,yyy.class);
 intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 startActivity(intent1);
TN888
  • 7,659
  • 9
  • 48
  • 84
Sudha
  • 505
  • 1
  • 10
  • 27

1 Answers1

0

Use your service to send an Intent to your second activity with a special value as an extra, then override the onNewIntent and check to see if the extra value is present; if its there you should stop your activity then use the finish() function to end your activity(as well you can use moveTaskToBack(true) to hide your activity). I highly recommend you to read this question.

Community
  • 1
  • 1
gst
  • 828
  • 5
  • 15