【问题标题】:Why GCM is not coming on some phones?为什么 GCM 没有出现在某些手机上?
【发布时间】:2015-07-10 13:53:37
【问题描述】:

我在某些手机上无法收到通知时遇到了一些问题。我也没有收到 GCM 意图。这是我调用 GCM 注册时的日志。在 Nexus、Moto 等手机上运行得非常好。但是在像 Lava 和 Karbonn 这样的低端手机上,我遇到了这个问题。

D/GCM (950): GcmService 启动 Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService (有附加功能)} com.google.android.c2dm.intent.REGISTER

V/ActivityManager(649): 广播: Intent { act=com.google.android.intent.action.GCM_RECONNECT flg=0x14 (has extras) } ordered=true userid=0 callerApp=null

D/ActivityThread(950):BDC 调用 onReceive:intent=Intent { act=com.google.android.intent.action.GCM_RECONNECT flg=0x14(有附加功能)},ordered=true,receiver=com.google .android.gms.gcm.bf@41f4f2e0, IIntentReceiver=41efeef8

D/PowerManagerService(649):acquireWakeLockInternal:lock=1114432392,flags=0x1,tag="GCM_CONN_ALARM",ws=WorkSource{10009 com.google.android.gms},uid=10009,pid=950

D/PowerManagerNotifier(649): onWakeLockAcquired: flags=1, tag="GCM_CONN_ALARM", packageName=com.google.android.gms, ownerUid=10009, ownerPid=950, workSource=WorkSource{10009 com.google.android .gms}

D/dalvikvm(950): threadid=22 (GCMWriter): 调用 run()

D/PowerManagerService(649):acquireWakeLockInternal:lock=1114432392,flags=0x1,tag="GCM_CONN_ALARM",ws=WorkSource{10009 com.google.android.gms},uid=10009,pid=950

D/dalvikvm(950): threadid=26 (GCMWriter): 调用 run()

D/PowerManagerService(649):releaseWakeLockInternal:lock=1114432392 [GCM_CONN_ALARM],flags=0x0,total_time=150ms

D/PowerManagerNotifier(649): onWakeLockReleased: flags=1, tag="GCM_CONN_ALARM", packageName=com.google.android.gms, ownerUid=10009, ownerPid=950, workSource=WorkSource{10009 com.google.android .gms}

这是我的清单文件

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<PACKAGE>"><uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />


<permission android:name="<PACKAGE>.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="<PACKAGE>.permission.C2D_MESSAGE" />

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


<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />


<application
    android:name="<PACKAGE>.ApplicationSingleton"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">

    <activity
        android:name="<PACKAGE>.ui.activity.WalkThroughActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>


    </activity>


    <receiver
        android:name="<PACKAGE>.gcm.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >

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

    </receiver>

    <service android:name="<PACKAGE>.gcm.GcmIntentService" />

    <activity
        android:name="<PACKAGE>.ui.activity.VendorDetailActivity"
        android:screenOrientation="portrait"
        android:theme="@style/NoTitleDialog"/>

    <activity
        android:name="<PACKAGE>.ui.activity.HomeActivity"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize"
        android:configChanges="keyboardHidden|orientation|screenSize">
    </activity>

    <service android:name="com.google.android.gms.analytics.AnalyticsService"
        android:enabled="true"
        android:exported="false"/>

    <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
        android:enabled="true">
        <intent-filter>
            <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
        </intent-filter>
    </receiver>


    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

</application>

【问题讨论】:

    标签: android google-maps push-notification google-cloud-messaging android-manifest


    【解决方案1】:

    只要设备至少运行 Android 2.2 版、安装了 Play 商店应用并登录了 Google 帐户,GCM 就应该可以工作。

    确保帐户同步也切换为开启。

    【讨论】:

    • 通知是一天前在同一部手机上发出的,现在它给出了这个错误。我编辑了我的日志。我是否必须更改清单文件中的某些内容才能使其在低端手机上运行?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 2018-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多