4

I am using moveTasktoBack() function to send my activity to background. I want to bring my activity to front when a timer in my activity finishes. I am using the phone back key to send the activity to back. How do I do that? Help please.

Jacob
  • 77,566
  • 24
  • 149
  • 228
James
  • 13,891
  • 26
  • 68
  • 93

3 Answers3

4

Exact Same issue that is mentioned on this Question.

Sloved it with following code snippet. i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); actauul which brings back the activity to front.

Intent i=new Intent(ApplicationStatus.this,NotifyActivity.class);
                    //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    i.putExtra("ID_TimeLeft",String.valueOf(TimeLeft));
                    startActivity(i);
DeltaCap019
  • 6,532
  • 3
  • 48
  • 70
2

I think it should be FLAG_ACTIVITY_SINGLE_TOP.

0

You can use intent with the appropriate flags. FLAG_ACTIVITY_NEW_TASK to create a new task to contain your activity if one doesn't already exist. FLAG_ACTIVITY_REORDER_TO_FRONT to bring your activity to the front of the task if it's not already there.

Intent intent = new Intent(context, YourActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);

context.startActivity(intent);
lastoneisbearfood
  • 3,955
  • 5
  • 26
  • 25