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
  • 75,331
  • 23
  • 142
  • 223
James
  • 13,523
  • 26
  • 66
  • 92

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,436
  • 2
  • 46
  • 69
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,705
  • 5
  • 25
  • 24