I have 3 main classes in the application
1) Intent service: when I receive a push notification and open activity in accordance with the notification message and other behaviors of the two classes. below is the code that does this
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 a mediator screen, therefore, if the application does not work, this screen will be displayed first, and after clicking the βyesβ button on this screen, MainScreen will open and this screen will be completed.
3) Main screen: This is the main screen of the application that displays the map. its main behavior is that ts a launchmode="singletask" mentioned in the manifest file, which means that if this screen works, its hole data will be sent to the onNewIntent() method, and not to open that screen again.
Now what happens in the stream,
Step 1: the application is in the background and a push notification appears. the condition is started, and the second condition is successful, and the intent of the screen is removed.
Step 2: On the notification screen, I press the "you" button to go to the next main screen.
Step 3: On the main screen, I process this information and complete the task or just close the application
Step 4: a new notification is received again, and since the application does not work, it goes into the second condition and launches the intention for the notification screen, but this time the notification screen does not start, and its intention does not appear, and the main screen starts, which is incorrect.
This is the abnormal behavior that I came across, instead of providing a notification class screen for the main intent screen, which is a completely different application behavior according to android.
Any help from anyone who encounters such a problem would 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 phone I'm testing in is "YU Yureka", this is its specification link . He currently has Android 5.0.2 OS
Third editor
To test this behavior, I debugged the code from the eclipse debugger. To test this, I set a breakpoint in NotificationScreen onResume and onCreate , but it was not deleted, not onResume from MainScreen .
I also added logs to the if and else condition, but still logs the else else condition.
Fourth edit Global.isMainScreenRunning : a global boolean variable that runs in onPause from MainScreen false and onResume in MainScreen in MainScreen .
Global.NotificationScreenRunning : a global boolean variable that runs in onPause from NotificationScreen and runs true in onResume NotificationScreen .