我正在开发一款应该使用GCM来发送通知的Android应用。
目前,我遇到设备问题< = Android 4.0.4。
使用我的Galaxy Nexus(4.3),Nexus 7“(4.3)和富士通平板电脑(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>
答案 0 :(得分:1)
从你的清单中引用:
<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>
元素中的权限应相同。