Receive GCM notification even when the app is closed (slide/swiped away)
Closing the app by sliding it (more commonly known as swiping it away) doesn't totally kill the app. Check out this answer in Android Enthusiasts community for a more detailed description. You can see there that it is mentioned that:
..It won't directly causes services to stop..
Since listeners for GCM notifications are Service
s, this would actually mean that there is still a possibility that your app may still continue to receive them regardless if it is swiped away.
Though the result of swiping an app may also differ depending on the device it is running, one may kill/force stop it or other just as mentioned above, will stop background processes.
If the result is, however, the app is killed/force stopped, as mentioned in the answer from the link above:
For stop is a complete kill of the app -- all processes are killed, all services stopped, all notifications removed, all alarms removed, etc.
Which would result for the app to don't receive any kind of notifications at all, as it was designed for Android since version 3.1, as stated in this answer:
Apps that are in the stopped state do not receive broadcast Intents.
Stopped state is:
when the app is initially installed (before the user runs something in the app) or
after a Force Stop.
You can find more about this here: http://developer.android.com/about/versions/android-3.1.html#launchcontrols
Hope this helps clear some things somehow. Cheers! :D
GCM push notification works after app Force Stop?
Once you force-stop your app from Settings, your code will not run until something manually runs one of your components (ie the user manually launches an activity).
Therefore after force-stopping your app from Settings, you will not receive GCM messages.
If you want to get notifications you have to manually restart your app.
This is by design since Android 3.1.
Apps that are in the stopped state do not receive broadcast Intents.
Stopped state is:
- when the app is initially installed (before the user runs something in
the app) or - after a Force Stop.
You can find more about this here: http://developer.android.com/about/versions/android-3.1.html#launchcontrols
When the app was terminated or the back ground is implemented, the push notification doesn't launch
(For Android) It may be because of some changes starting from Android 3.1 where Launch controls behavior which when a stopped application will stop receiving any notification as "Apps that are in the stopped state do not receive broadcast Intents." Check this related SO question and GCM push notification.
Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications. A background service or application can override this behavior by adding the FLAG_INCLUDE_STOPPED_PACKAGES flag to broadcast intents that should be allowed to activate stopped applications.
Applications are in a stopped state when they are first installed but are not yet launched and when they are manually stopped by the user (in Manage Applications).
Hope this information helps!
Firebase Cloud Messaging Service - Receive Notifications even when app is killed
If the app is killed/force stopped, as mentioned in the answer from the link above:
Force stop is a complete kill of the app -- all processes are killed, all services stopped, all notifications removed, all alarms removed, etc.
Which would result for the app to don't receive any kind of notifications at all, as it was designed for Android since version 3.1, as stated in this answer:
Apps that are in the stopped state do not receive broadcast Intents.
Stopped state is:
when the app is initially installed (before the user runs something in the app) or
after a Force Stop.
You can find more about this here: http://developer.android.com/about/versions/android-3.1.html#launchcontrols
Just a retrieved a portion from my answer here. Check out the thread, it may also be helpful for you.
GCM push & application process
Referring following table we can say that, App will not get Push notification if Forced closed by user manually.
However if App is killed by system in case of low memory, BroadcastReceiver
will get notified and Push notification will be received by device.
Source of comparison table.
Related Topics
How to Set Relativelayout Layout Params in Code Not in Xml
How to Disable Past Dates in Android Date Picker
Android Saving Created Bitmap to Directory on Sd Card
How to Make an Application Ignore Screen Orientation Change
Listing All Extras of an Intent
Fade in Fade Out Android Animation in Java
Navigation Drawer: How to Set the Selected Item at Startup
Call Method When Home Button Pressed
Removing Log Call Using Proguard
Comparing Two Drawables in Android
Gradle Build Tool Cannot Find Play-Services-Tasks.Aar? Why
Dynamic Form with Repeating Form
Settext Fails to Show a Number as Text in a Textview
How to Globally Force Screen Orientation in Android
Generate Bitmap from HTML in Android
Overflow Auto Doesn't Work in Android Browser