GcmListenerService is not called while application stopped. Android GCM

妖精的绣舞 提交于 2019-12-12 02:31:46

问题


My manifest file is as below:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<permission android:name="com.example.app.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.example.app.permission.C2D_MESSAGE" />

 <application
    android:name="com.example.app"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"

...activities..

 <receiver
        android:name=".GcmBroadcastReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>

            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <category android:name="com.example.app" />
        </intent-filter>
    </receiver>

  <service
        android:name=".GCMPushReceiverService"
        android:exported="false">
        <intent-filter >
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>

 <!--             GCM Registration Intent Service -->
    <service
        android:name=".GCMRegistrationIntentService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>
   </application>

Where GcmBroadcastReceiver extends GcmReceiver and GCMPushReceiverService extends GcmListenerService. No methods inside either of this class is triggered when the application is stopped.

来源:https://stackoverflow.com/questions/38393678/gcmlistenerservice-is-not-called-while-application-stopped-android-gcm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!