TheSquad
TheSquad

Reputation: 7506

Android GCM not receiving notification when Service has been killed

I know there is a lot of questions about this, but every time the issue where because they were "force-killing" their app through the App Manager.

This isn't my case.

I run a service, that should handle the GCM Notification. When the service is running, everything works just fine !

BUT

If I launch another App really eager of RAM, let's say Something like a game, the Android will kill my service (in order to restart it later when RAM is no more an issue).

The thing is, If I start the said game, and send while the game is running (when I'm sure that the service has been killed by the device -- looking at running processes on Eclipse), it does not get any messages... Until I stop the game, wait like 3-4 minutes (probably for the GC to come around) then, and only then (when the service is restarted) I get the GCM Notifications.

The entry point of the application makes me think that the service is restarted because RAM usage was low enough to start my service back, and not because GCM received a notification.

Is that a normal behavior of GCM notification system ? Is their any way to get the service run as soon as I get a GCM notification ?

Here's what's in the manifest :

<receiver
        android:name="com.my.package.service.C2DMMessageReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>

        <category android:name="com.my.package.service"/>
    </intent-filter>
</receiver>

And Here's the entire class C2DMMessageReceiver :

public class C2DMMessageReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
            Log.d("C2DM", "#### GOT PUSH ####");
            Communication2.getInstance().reconnect();
        }
    }
}

Upvotes: 0

Views: 1281

Answers (1)

Nasif Noorudeen
Nasif Noorudeen

Reputation: 142

This is by default by design. Starting from android 3.1 and above any application user removed from the tasks or application manager wont receive any intents broadcasted , based on the following conditions....

https://developer.android.com/about/versions/android-3.1.html#launchcontrols

Upvotes: 0

Related Questions