Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCM push notification works after app Force Stop?

I have used GCM to get push notifications, now if I Force stop the app from the settings on the Android device, will it be able to get push notifications?

I have read many posts that say in this case an app cannot receive notifications.

Is there any possibility to get notifications?

like image 873
Yagnesh Avatar asked Dec 30 '13 11:12

Yagnesh


People also ask

How does GCM push notification work?

The first step in GCM is that a third-party server (such as an email server) sends a request to Google's GCM server. This server then sends the message to your device, through that open connection. The Android system looks at the message to determine which app it's for, and starts that app.

How do I get notifications when an app is closed Android?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I force push notifications on Android?

Go to Settings > Notifications & status bar > Notification Manager > select the app and turn on "Allow Notifications", "Display on Lockscreen", "Display at the top of the screen", "Notification Sound and Vibration", and "Priority notification". Then, restart your phone.


1 Answers

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

like image 157
benka Avatar answered Oct 08 '22 13:10

benka