I am using Android native MFP sdk. I am trying to implement push notifications.
As per the doc MFP is asking to put
<activity
android:name=".controllers.activities.MyActivity"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.mypackage.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I am binding the NOTIFICATION intent filter to a activity.
The issue is I have atleast 10 activities in my android app and When my app is in foreground i receive a push onmessage method is called i can get the notification into app.
When my app goes to background and I get a push notification then thats a issue. I launch my app with the above activity but i move on to different activities then i send my app to background now if i get a push notification it lands in the notification bar until now everything works fine. But when i click on the notification it bring my app to foreground and goes to the above mentioned activity MyActivity and kills the presents activity.
Can some body tell me how do i stop this happening i want it to stay on the activity it is and still receive the push.
I know i can use service to receive it but the Mobilefirst is not allowing me to edit the broadcast and service that is already defined in the Mobilefirst sdk.
How do i do that?
Finally i got some solution.
I have created a dummy activity and binding the above mention code to it.`
<activity
android:name=".controllers.activities.DummyActivity"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="com.mypackage.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
If my app is in background and app gets a notification . On clicking of Notification it will open the dummyactivity and i am calling finish() method in the onResume(). So this particular activity will be finished even before it is opened which will open the pervious activity and I am putting a check saying applaunched if it is false, I am relaunching the app.
This cant be a straight solution but it is a work around for now.