Nick
Nick

Reputation: 575

Bring app in background to front

I am making an app that gives an alarm when you are close to a gps position. now when a user presses the home button this app get send to the back. When the users enters the region to trigger the alarm, the alarm triggers but the app isn't send to the foreground. How can i do this?

I tried this

            Intent intent = new Intent(context, TrainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 
            intent.setAction(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            startActivity(intent);

in the function of the alarm, but this does nothing? (Trainactivity is the class that runs on the background and the class that needs to be on the foreground)

Upvotes: 0

Views: 1472

Answers (1)

Deepak Bala
Deepak Bala

Reputation: 11185

The REORDER_TO_FRONT flag only controls the stacking order on the activity history. That is not what you want. Is this what you are looking for ? - Bring application to front after user clicks on home button

Upvotes: 1

Related Questions