在Android的C2DM消息混乱 [英] confusion with c2dm messaging in android

查看:121
本文介绍了在Android的C2DM消息混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了使用此C2DM code 的http:// www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html 。它works.i上午收到推送通知,从服务器,但问题是,每当我从服务器发送通知发送旧notification.It仅发送当前的新通知时注册我的Andr​​oid设备,并发送注册ID给server.Please建议我应该是什么issue.Thanks提前..

i have implemented a small demo that uses this c2dm code http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html .it works.i am getting push notifications from server but the problem is whenever i send notification from server it sends old notification.It only sends current new notification whenever i register my android device and send registration id to server.Please suggest me what should be the issue.Thanks in advance..

推荐答案

据我从我跟着拉尔斯·沃格尔的教程我记得,我有同样的问题。这其实不是你已经指出的问题。

As far as I remember from when I followed Lars Vogel's tutorial myself, I had the same problem. It's actually not the problem that you have stated.

尝试把一个断点在的onReceive()函数来手动看到你所得到的有效载荷。在我的情况下,消息是好的,但 MessageReceivedActivity 不是,它总是呈现坏消息。

Try putting a breakpoint in the onReceive() function to manually see the payload you are getting. In my case, the message was good, but the MessageReceivedActivity was not, and it was always showing the bad message.

从MessageReceivedActivity把 super.onCreate()方法的方法之上。

Put the super.onCreate() method from the MessageReceivedActivity on top of the method.

如何为:

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_result);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        String message = extras.getString("payload");
        if (message != null && message.length() > 0) {
            TextView view = (TextView) findViewById(R.id.result);
            view.setText(message);
        }
    }

    super.onCreate(savedInstanceState);
}

应如何:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_result);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        String message = extras.getString("payload");
        if (message != null && message.length() > 0) {
            TextView view = (TextView) findViewById(R.id.result);
            view.setText(message);
        }
    }
}

这篇关于在Android的C2DM消息混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆