I sometimes have a problem with my GCM service, which closes when the RAM of my smartphone is automatically cleared (read this if you need more information).
As I understand it, if I installed my service to work in the foreground, it should help the system remove it using RAM. The Service.class method onStartCommand() usually used to start the startForeground() method.
But with the latest version of the GCM implementation, this is not possible, since the onStartCommand() method of the parent GCMListenerService.class is defined as final , and I cannot override it.
So, how can I install the gcm receiver on the rum in the foreground?
Here is my manifest part about GCM.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.app.path" > <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <permission android:name="my.app.path.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="my.app.path.permission.C2D_MESSAGE" /> <application ...> <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="my.app.path" /> </intent-filter> </receiver> <service android:name=".MyGcmListener" android:exported="false" android:enabled="true" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service> </application> </manifest>
Thanks in advance.
android google-cloud-messaging
user2957954
source share