应用程序停止时不会调用GcmListenerService。 Android GCM

时间:2016-07-15 10:21:00

标签: android google-cloud-messaging android-service

我的清单文件如下:

<?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>

GcmBroadcastReceiver extends GcmReceiverGCMPushReceiverService extends GcmListenerService的位置。当应用程序停止时,不会触发此类中的任何方法。

0 个答案:

没有答案