简体   繁体   中英

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM