I\'m receiving that error from Android Studio\'s Android Monitor. This error appears when I send a push notification through GCM, in a real device, and the app has not been
So... I solved the problem. The problem was that the device is not registered to receive GCM if the app is force closed or if the app has never been opened since device boot. The solution is simple, register the device on phone boot. For this, I implemented a BroadcastReceiver
and started a process registration inside it.
The modifications:
Added to AndroidManifest
<receiver android:name="com.flagg327.guicomaipu.gcm.OnBootBroadcastReceiver">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
OnBootBroadcastReceiver.java
public class OnBootBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent("com.flagg327.guicomaipu.gcm.RegistrationService");
i.setClass(context, RegistrationService.class);
context.startService(i);
}
}
So, on boot, the device will register into the GCM server and going to be able to receive any push notification from my server. I hope it is useful.
For me it was the case that AutoStart functionality for my app was provided. Go to settings select your installed app and enable AutoStart. This will fix the issue.