您好,我想在我的 android 应用程序中实现 Google 的 GCM。
我链接到谷歌播放服务库
我写了以下权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.torasecurity.mobile.alarm.RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.torasecurity.mobile.alarm.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.torasecurity.mobile.alarm.C2D_MESSAGE" />
一个简单的广播接收器:
<receiver android:name=".MyReceiver" android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="YOUR_PACKAGE_NAME" />
</intent-filter>
</receiver>
但是我在尝试注册时得到了这个堆栈跟踪:
08-07 11:43:12.806: W/System.err(19067): java.io.IOException: MAIN_THREAD
08-07 11:43:12.826: W/System.err(19067): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
08-07 11:43:12.826: W/System.err(19067): at com.torasecurity.mobile.alarm.SplashScreen.register(SplashScreen.java:27)
08-07 11:43:12.826: W/System.err(19067): at com.torasecurity.mobile.alarm.SplashScreen.onCreate(SplashScreen.java:56)
08-07 11:43:12.826: W/System.err(19067): at android.app.Activity.performCreate(Activity.java:5206)
08-07 11:43:12.826: W/System.err(19067): at
有没有人知道我做错了什么?