我一直在努力奋斗着这个错误了很多,我便放弃了。每次我试图发送使用GCM在LogCat中出现此错误消息。什么我没有做什么?我跟着Android的例子建立GCM通知。 这是LogCat中错误
编辑:此消息实际上得到通过,但我不认为这误差属正常
08-12 17:13:15.888:W / GTalkService(2237):[DataMsgMgr]广播意图回调:结果=已取消forIntent {行为= com.google.android.c2dm。 intent.RECEIVE猫= [com.testing.encuesta](有群众演员)}
AndroidManifest.xml中
<允许机器人:名称=com.testing.encuesta.permission.C2D_MESSAGE
安卓的ProtectionLevel =签名/>
<使用-权限的Android:名称=com.testing.encuesta.permission.C2D_MESSAGE/>
<使用-权限的Android:名称=com.google.android.c2dm.permission.RECEIVE/>
<使用-权限的Android:名称=android.permission.INTERNET对>< /使用-许可>
<使用-权限的Android:名称=android.permission.VIBRATE>< /使用-许可>
<应用
机器人:allowBackup =真
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名称=com.testing.encuesta.MainActivity
机器人:标签=@字符串/ APP_NAME>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
<活动机器人:名称=。INICIO>
< /活性GT;
<接收机器人:GCMBroadcastReceiver名称=机器人:权限=com.google.android.c2dm.permission.SEND>
<意向滤光器>
<作用机器人:名称=com.google.android.c2dm.intent.RECEIVE/>
<类机器人:名称=com.testing.encuesta/>
&所述; /意图滤光器>
<意向滤光器>
<作用机器人:名称=com.google.android.c2dm.intent.REGISTRATION/>
<类机器人:名称=com.testing.encuesta/>
&所述; /意图滤光器>
< /接收器>
我班GCMBroadcastReceiver
公共类GCMBroadcastReceiver扩展的BroadcastReceiver {
@覆盖
公共无效的onReceive(上下文的背景下,意图意图){
尝试 {
串动= intent.getAction();
如果(action.equals(com.google.android.c2dm.intent.REGISTRATION))
{
串registrationID = intent.getStringExtra(registration_id);
Log.d(ID,registrationID);
字符串错误= intent.getStringExtra(错误);
字符串未注册= intent.getStringExtra(未登记);
}
否则如果(action.equals(com.google.android.c2dm.intent.RECEIVE))
{
字符串数据1 = intent.getStringExtra(数据1);
串数据2 = intent.getStringExtra(数据2);
Toast.makeText(背景下,DATA1,Toast.LENGTH_LONG);
}
}赶上(例外五){
Log.d(错误,错误连接C2DM+ e.toString());
}
}
解决方案
固定,你只需要添加的setResult code(Activity.RESULT_OK);在的onReceive()的结束;方法
I've been struggling with this error for a lot and I just gave up. Every time I try to send a message using GCM this error appears on LogCat. What I'm failing to do? I've followed Android examples to set up GCM Notifications. This is the LogCat Error
Edit: The message actually gets through but I don't think this error is normal.
08-12 17:13:15.888: W/GTalkService(2237): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.testing.encuesta] (has extras) }
AndroidManifest.xml
<permission android:name="com.testing.encuesta.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.testing.encuesta.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.testing.encuesta.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Inicio">
</activity>
<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.testing.encuesta" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.testing.encuesta" />
</intent-filter>
</receiver>
My class GCMBroadcastReceiver
public class GCMBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
String action=intent.getAction();
if(action.equals("com.google.android.c2dm.intent.REGISTRATION"))
{
String registrationID=intent.getStringExtra("registration_id");
Log.d("ID",registrationID);
String error=intent.getStringExtra("error");
String unregistered=intent.getStringExtra("unregistered");
}
else if(action.equals("com.google.android.c2dm.intent.RECEIVE"))
{
String data1=intent.getStringExtra("data1");
String data2=intent.getStringExtra("data2");
Toast.makeText(context, data1, Toast.LENGTH_LONG);
}
} catch (Exception e) {
Log.d("Error", "error en C2DM"+e.toString());
}
}
解决方案
Fixed, you just need to add setResultCode(Activity.RESULT_OK); at the end of the onReceive(); method
上一篇:如何在 cocos2d 中以编程方式创建新的 UIView?中以、方式、如何在、UIView
下一篇:通用ImageLoader的java.io.EOFExceptionjava、ImageLoader、EOFException、io