My minimized application calls AlertDialog . It has two buttons: OK and Cancel .
By Cancel, just close the AlertDialog , but using the OK button, you need to display the main activation of the application or just bring the application to the foreground.

How to do it?

Closed due to the fact that the essence of the issue is not clear to the participants Vladimir Glinskikh , tutankhamun , Visman , Nick Volynkin , Peter Olson 26 Aug '15 at 9:00 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    In the handler for clicking the OK button, create an Intent with the launch of your Activity and the flag FLAG_ACTIVITY_SINGLE_TOP or FLAG_ACTIVITY_CLEAR_TOP , depending on the required behavior:

     final Intent intent = new Intent(context, YourActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(intent); 
    • Suppose I displayed one activity in the foreground. If I move from it to another activity, will it also be in the foreground? - sitev_ru
    • @sitev_ru In the foreground, there can be only one activity - the last one triggered. Those that were before it go to the background and are added to the transition stack. SINGLE_TOP - takes activations on the top of the stack from a minimized state without creating a new instance (just "raises" it). CLEAR_TOP - does the same thing, but not for activating at the top of the stack, at the same time destroying the stack in front of it - (takes it to the top of the stack) / You can read the activation stack - pavlofff
    • Once again in a row: turned off the application, called the AlertDialog, from it called activated1, from activated1 I called activated2 ... So this activation2 exactly appears on the phone screen? - sitev_ru
    • @sitev_ru of course, where are the doubts? - pavlofff
    • And can I immediately remove my application from my minimized application (while another application is running on top) to activate my application without AlertDialog? - sitev_ru