我正在开发一个应该使用GCM传递通知的Android应用。

目前,我在
使用我的Galaxy Nexus(4.3),Nexus 7“(4.3)和Fujitsu Tablet(4.1.1),我可以正确接收来自GCM的广播,并显示通知。

但是使用HTC Incredible S(4.0.4)和HTC Flyer(3.2),该应用程序不会获得任何收益。实际上,在Eclipse中尝试调试模式时,在这些设备上运行的应用程序不会输入onReceive()方法。

这是我的AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.yyy"
    android:versionCode="3"
    android:versionName="1.2" >

    <uses-sdk
        android:minSdkVersion="8" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <uses-feature android:name="android.hardware.camera"></uses-feature>

    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <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_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_GPS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

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

    <permission android:name="com.seven.carserverapp.permission.C2D_MESSAGE"
                    android:protectionLevel="signature" />
    <uses-permission android:name="com.example.gcmpush.sevenit.permission.C2D_MESSAGE" />


    <permission
        android:name="com.xxx.yyy.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="com.xxx.yyy.permission.MAPS_RECEIVE"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        >

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

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

        </receiver>

        <!-- PRODUCTION KEY -->
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="googleapikey"/>


        <activity
            android:name="xxx.yyy.SplashScreen"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:noHistory="true"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name="Mappa" android:label="@string/title_Filiali" android:screenOrientation="portrait"></activity>
        <activity android:name="ParlaCon" android:label="@string/title_ContattiRapidi" android:screenOrientation="portrait"></activity>
        <activity android:name="Configurazione" android:label="@string/title_Login" android:screenOrientation="portrait"></activity>
        <activity android:name="IMieiDati" android:label="@string/title_DatiAnagr" android:screenOrientation="portrait"></activity>
        <activity android:name="ChiSiamo" android:label="@string/title_Noleggio" android:screenOrientation="portrait"></activity>
        <activity android:name="CompanyProfile" android:label="@string/title_CompanyProfile" android:screenOrientation="portrait"></activity>
        <activity android:name="GrandiAziende" android:label="@string/title_GrandiAziende" android:screenOrientation="portrait"></activity>
        <activity android:name="PMI" android:label="@string/title_PMI" android:screenOrientation="portrait"></activity>
        <activity android:name="Professionitsti" android:label="@string/title_Professionisti" android:screenOrientation="portrait"></activity>
        <activity android:name="FAQ" android:label="@string/title_FAQ" android:screenOrientation="portrait"></activity>
        <activity android:name="GuidaApp" android:label="@string/title_GuidaApp" android:screenOrientation="portrait"></activity>
        <activity android:name="IlMioNoleggio" android:label="@string/title_IlMioNoleggio" android:screenOrientation="portrait"></activity>
        <activity android:name="Main" android:label="@string/app_name" android:screenOrientation="portrait"></activity>
        <activity android:name="NewsSingola" android:label="@string/title_News" android:screenOrientation="portrait"></activity>
        <activity android:name="Km" android:label="@string/title_InsKM" android:screenOrientation="portrait"></activity>
        <activity android:name="KmResoconto" android:label="@string/title_ElencoKM" android:screenOrientation="portrait"></activity>
        <activity android:name="Manuale" android:label="@string/title_Manuale" android:screenOrientation="portrait"></activity>
        <activity android:name="ContattaConsulente" android:label="@string/title_ContattaConsulente" android:screenOrientation="portrait"></activity>
        <activity android:name="MainPublic" android:label="@string/app_name" android:screenOrientation="portrait"></activity>
        <activity android:name="PrevisioneConsegna" android:label="@string/title_PrevConsegna" android:screenOrientation="portrait"></activity>
        <activity android:name="CentriAssistenza" android:label="@string/title_CentriAssistenza" android:screenOrientation="portrait"></activity>
        <activity android:name="CentriAssistenzaMappa" android:label="@string/title_CentriAssistenza" android:screenOrientation="portrait"></activity>
        <activity android:name="CentroAssistenzaSingolo" android:label="@string/title_CentriAssistenza" android:screenOrientation="portrait"></activity>
        <activity android:name="ServiziContratto" android:label="@string/title_ServiziContratto" android:screenOrientation="portrait"></activity>

    </application>

</manifest>

最佳答案

引用清单中的内容:

<permission android:name="com.seven.carserverapp.permission.C2D_MESSAGE"
                android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcmpush.sevenit.permission.C2D_MESSAGE" />


权限应为YOUR_PACKAGE.permission.C2D_MESSAGE,并且在<permission>元素和<uses-permission>元素中应相同。

关于android - 某些设备上的Google云消息传递错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18406564/

10-10 04:55