我正在开发一个应该使用 GCM 来传递通知的 Android 应用程序。
目前,我遇到了设备 <= Android 4.0.4 的问题。
使用我的 Galaxy Nexus (4.3)、Nexus 7" (4.3) 和 Fujitsu 平板电脑 (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>