I've followed the Firebase Quickstart Messaging Tutorial, and I've a problem.
I'd like to launch the two services (MyFirebaseMessagingService and MyFirebaseInstanceIDService) on the boot of the system.
For that, I've added the RECEIVE_BOOT_COMPLETED permission to my AndroidManifest.xml.
I've also added this to the Manifest :
<receiver android:name=".AutoStart">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
In my AutoStart class, there is this :
@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, MyFirebaseInstanceIDService.class));
context.startService(new Intent(context, MyFirebaseMessagingService.class));
}
The two services are nearly the same as on the links I've provided above. And my MainActivity only contains a few Views.
But it doesn't work : as soon as the services are launched, the services are automatically killed and I get a message like this in the logcat :
I/ActivityManager﹕ Killing 3100:com.company.E/u0a85 (adj 15): empty #17
I've searched for solutions about this "killing problem", and I think I've found something interesting here (about WakefulBroadcastReceiver).
If this part of the solution, I met another problem with this answer...
The onHandleIntent() override method he talks about is part of IntentService where my two services are Service.
If this is not part of the solution, I don't know how to prevent my app to be killed...