android 信鸽 自动重启,android,_研究了一下腾讯信鸽的demo,感觉里面一个自定义handler类有问题,android - phpStudy...

研究了一下腾讯信鸽的demo,感觉里面一个自定义handler类有问题

这是该handler的代码

private static class HandlerExtension extends Handler {

WeakReference mActivity;

HandlerExtension(MainActivity activity) {

mActivity = new WeakReference(activity);

}

@Override

public void handleMessage(Message msg) {

super.handleMessage(msg);

MainActivity theActivity = mActivity.get();

if (theActivity == null) {

theActivity = new MainActivity();

}

if (msg != null) {

Log.w(Constants.LogTag, msg.obj.toString());

TextView textView = (TextView) theActivity

.findViewById(R.id.deviceToken);

textView.setText(XGPushConfig.getToken(theActivity));

}

// XGPushManager.registerCustomNotification(theActivity,

// "BACKSTREET", "BOYS", System.currentTimeMillis() + 5000, 0);

}

}

注意handleMessage方法里,

if (theActivity == null) {

theActivity = new MainActivity();

}

这样的用法明显不对啊,Activity实例是系统调用生成的,手动new没有任何作用,各个生命周期方法(onCreate等)也不会被调用。既然theActivity == null,那多半就意味着这个Activity已经被用户正常关闭,也没有必要再使用它了。

相关阅读:

mysql插入文本如果是个sql语句就报错了

PHP 调用soap接口

linux,xp双系统,xp过热

mac上的idea一直找不到jdk

Python 字符串转数字

socket.io 和 socketJs 的区别是什么?

以root身份安装的sudo,其它用户使用时为什么要输入密码?

tableview的cellForRow方法崩溃

iOS 表格刷新后页面的位置会改变

session 存入数据库的作用

什么原因会导致font-face字体图标在电脑浏览器下无法正常显示?

window server2012服务器上迅速找出被挂马的文件

UIWebview 在线视频播放 ipad上有声音无图像

rsync执行错误MAC

被这个算法迷住了,如何获得一个加密函数?

C++使用libcurl下载文件,传入url失败?CURLE_URL_MALFORMAT

android视频硬解

input type number 数值问题

请问sublime text3能否快速实现此功能:给选中的文字两端加上HTML标签?

Mac编辑sudoers文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值