Launching activities to the forefront of service

Basically, I want to bring the dialogue to the forefront from the background service (I know that using a notification will be more convenient for the user, but my application really needs an immediate response from the user). I have a job. Then I define the action containing the dialog using android:theme="@android:style/Theme.Translucent.NoTitleBar" .

In the utility code, I start the dialog operation as follows:

 Intent intent = new Intent(getApplicationContext(), PopUpDialogActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); 

A dialog may appear if I'm in my application. But if I am not in my application, the dialogue does not appear in the foreground (I must enter my application to see it). How can I run it directly in user focus?

+4
source share
1 answer

If your service is tied to activity, it will die when you exit your activity or application. Use onPause () and onResume () to untie and bind to the service so that it does not die on exit / return.

0
source

Source: https://habr.com/ru/post/1395659/


All Articles