I have 3 major class in the application
1) Intent service: where I receive push notification and open activity according to notification message and other two classes behavior. below is the code which does that
if(Global.isMainScreenRunning){
Intent intent = new Intent(this, MainScreen.class);
intent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else if(!Global.NotificationScreenRunning){
Intent intent = new Intent(this, NotificationScreen.class);
intent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
2) NotificationScreen : This is the mediator screen so if the application is not running this screen will be shown first and on click of yes button of this screen MainScreen will be opened and this screen will be finished.
3) Main screen: This is the main screen of the application which show map. its core behavior is that ts a launchmode="singletask"
mentioned in menifest file, which means if this screen is running its hole data will be sent to onNewIntent()
method rather than opening this screen again.
Now what is happening in flow is
Step 1: application is in background and push notification comes. condition run and the second condition gets success and notification screen intent is shot
step 2: In notification screen I click on ye button to move on to the next main screen
step 3: In Main screen I process this info and perform task or just close the application
Step 4: again a new notification is received and as the application is not running is goes to second condition and start the intent for notification screen but this time no notification screen is launched instead of providing its intent and main screen is launched which is wrong.
This is the abnormal behavior which I am facing that instead of providing class of notification screen for intent main screen is launched which is totally different behavior of application according to android.
Any help from any one who come across such problem will be greatly appreciated.
Edit
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.front" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.microphone" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.example.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.app.permission.C2D_MESSAGE" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:allowBackup="true"
android:icon="@drawable/android_app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".SplashScreen"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainScreen"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask"
android:excludeFromRecents="true"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".NotificationScreen"
android:configChanges="keyboardHidden|orientation"
android:excludeFromRecents="true"
android:screenOrientation="portrait" >
</activity>
<receiver
android:name=".pushnotification.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.selebrety.app" />
</intent-filter>
</receiver>
<service android:name=".pushnotification.GcmIntentService" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
Second Edit
The mobile in which I am testing is "YU Yureka" here is its specification link. Current it have android 5.0.2 OS
Third Edit
To test this behavior I have debugged the code from eclipse debugger. To check this I have put a break point in NotificationScreen
onResume
and onCreate
but it was never hit instead of onResume
of MainScreen
is hit.
Also I added a logs in if and else condition but still logs for else condition is printed.
Fourth Edit
Global.isMainScreenRunning
: is global boolean
variable which is done false in onPause
of MainScreen
and done true in onResume
of MainScreen
.
Global.NotificationScreenRunning
: is global boolean
variable which is done false in onPause
of NotificationScreen
and done true in onResume
of NotificationScreen
.