Reputation: 5634
I would like to achieve something opposite to this issue: Dialog Activity also resumes other activities in the background
I have a dialog activity defined in AndroidManifest.xml
file in this way:
<activity
android:name="com.myapp.activity.CloudMessageDialogActivity"
android:parentActivityName="com.myapp.activity.MyParentActivity"
android:excludeFromRecents="true"
android:theme="@android:style/Theme.Holo.Light.Dialog.NoActionBar">
</activity>
I would like to resume my parent activity in the background with my dialog activity. User opens my dialog activity from the notification in the action bar.
A this moment I have two scenarios:
When my app is running in the background. Choosing the notification from action bar will open the dialog activity with the parent activity running in the background.
When my app is not running in the background. Only the dialog activity will be opened.
Is this possible to open dialog activity with the parent activity running in the background all the time? Without of course switching dialog activity to the dialog fragment.
Upvotes: 1
Views: 989
Reputation: 4708
The PendingIntent associated with your notification should launch your Activity, not the dialog directly.
Add an Extra
in this intent in order to detect that it should open the dialog.
then in the onResume
method of your activity, read the extra ( getIntent.getExtra()...
) and if it should, open the dialog there.
So in every case, your activity will be resumed before your dialog is displayed.
Upvotes: 1