调试android中的jpush的代码。

发现:

set alias的callback中,返回错误代码6012

所以去搜索:

jpush 6012

找到:6012在JPush服务stop状态下设置了tag或alias3.0.0版本新增的错误码。开发者可根据这个错误码的信息做相关处理或者提示。

所以清楚了:

jpush的android的sdk 是3.0.0之后才增加的错误码。

原因是jpush服务还没启动,结果就去调用了onPause导致的。

另外:

中看到了:

onCreate中

JPushInterface.init(this);

之前有个:

JPushInterface.setDebugMode(true);

所以去加上:JPushInterface.setDebugMode(true);

JPushInterface.init(this);

这样可以获得更多的调试信息

后来发现是:

app启动时,没有启动JPUSH服务,结果就在login时的onPause时去暂停了jpush:@Override

protected void onPause() {

JPushInterface.onPause(this);

super.onPause();

}

所以导致返回报错6012,在没有启动jpush时就去暂停。

其中是看到了jpush输出log中提示:

[ServiceInterface] The service is stopped, it will give up all the actions until you call resumePush method to resume the service.

所以去加上resumePush:@Override

protected void onResume() {

JPushInterface.onResume(this);

JPushInterface.resumePush(this);

super.onResume();

}

其中也看到,已经有了:

JPushInterface.onResume(this);

但貌似没有起到效果。

后来又发现,app用户注销后,结果调用了onPause

-》JPushInterface.onPause(this);

-》关闭了jpush的服务

-》所以此处为了保证逻辑正确,就注释掉这个onPause:@Override

protected void onPause() {

//        if (!JPushInterface.isPushStopped(this)) {

//            JPushInterface.onPause(this);

//        }

super.onPause();

}

因为消息推送逻辑应该是:当用户登录成功后,启动jpushsetAlias或setTag

但用户注销(成功)后,,关闭jpush清除alias或tag

然后继续调试发现此处app:用户注销时,是调用关闭jpush服务了JPushInterface.stopPush(SellCarApplication.getAppContext());

但是用户重新登录时,却没有再去开启jpush服务所以自己去加上:

JPushInterface.resumePush(LoginActivity.this);

调试期间的log是:11-10 18:58:08.350 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JPush: [JPushInterface] action:init – sdkVersion:3.0.0, buildId:316

11-10 18:58:08.391 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JPush: [AndroidUtil] action:checkValidManifest

11-10 18:58:08.681 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JPush: [ServiceInterface] The service is stopped, it will give up all the actions until you call resumePush method to resume the service.

11-10 18:58:09.010 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JPush: [JPushInterface] action:resumePush

11-10 18:58:09.159 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JCore: [PushService] onStartCommand – intent:Intent { act=run.action cmp=com.chumi.sellcar.stress/cn.jpush.android.service.PushService (has extras) }, pkg:com.chumi.sellcar.stress, connection:0

11-10 18:58:09.163 9426-9788/com.chumi.sellcar.stress D/JIGUANG-JCore: [ARunAction] Bundle[{action=cn.jpush.android.intent.REPORT, report.extra.info=, report=crash_log, sdktype=JCORE}]

11-10 18:58:09.166 1479-2672/? W/WakePathChecker: MIUILOG-WAKEPATH: call was rejected by wakepath. userId= 0 caller= com.chumi.sellcar.stress callee= com.hupu.games classname=cn.jpush.android.service.DaemonService action=null wakeType=8

11-10 18:58:09.192 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JCore: [PushService] onStartCommand – intent:Intent { act=cn.jpush.android.intent.RESTOREPUSH cmp=com.chumi.sellcar.stress/cn.jpush.android.service.PushService (has extras) }, pkg:com.chumi.sellcar.stress, connection:0

11-10 18:58:09.206 9426-9788/com.chumi.sellcar.stress D/JIGUANG-JPush: [JPushDataAction] Action – onActionRun

11-10 18:58:09.230 9426-9788/com.chumi.sellcar.stress D/JIGUANG-JPush: [PushServiceCore] bundle:Bundle[{action=cn.jpush.android.intent.RESTOREPUSH, app=com.chumi.sellcar.stress, sdktype=JPUSH}]

11-10 18:58:09.231 9426-9788/com.chumi.sellcar.stress D/JIGUANG-JPush: [PushServiceCore] Action – handleServiceAction – action:cn.jpush.android.intent.RESTOREPUSH

11-10 18:58:09.322 9426-9811/com.chumi.sellcar.stress D/JIGUANG-JCore: [ConnectingHelper] To get sis – host:s.jpush.cn, port:19000, selection:0

11-10 18:58:09.389 9426-9811/com.chumi.sellcar.stress I/JIGUANG-JCore: [ConnectingHelper] Get sis info succeed with host: s.jpush.cn

11-10 18:58:10.796 9426-9426/com.chumi.sellcar.stress D/JPush: [MyReceiver] onReceive – cn.jpush.android.intent.CONNECTION, extras:

key:cn.jpush.android.APPKEY, value:74e686ba55ab5b0b3a5a1468

key:cn.jpush.android.CONNECTION_CHANGE, value:true

11-10 18:58:10.796 9426-9426/com.chumi.sellcar.stress W/JPush: [MyReceiver]cn.jpush.android.intent.CONNECTION connected state change to true

11-10 18:58:15.927 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JPush: [JPushInterface] action:resumePush

11-10 18:58:15.928 9426-9426/com.chumi.sellcar.stress D/JIGUANG-JPush: [ServiceInterface] service is running already

11-10 18:58:16.084 9426-9426/com.chumi.sellcar.stress D/JPush: Set alias in handler.

。。。

事后:

觉得JPushInterface的那个onResume 很是诡异。

所以去搜搜看看:

JPushInterface onResume

JPushInterface onResume resumePush

【总结】

此处是app代码内部逻辑比较混乱导致jpush没有启动,所以收不到推送。

所以在还没启动时就调用stopPush导致触发6012错误。

去改动对应代码,即可。

总体逻辑参考:API – init

API – stopPush

API – resumePush

API – isPushStopped

所以,写代码其时,要注意在合适的时机触发对应的功能

1.最开始初始化是调用init

2.用户登录(服务器)成功后,调用resumePush -》确保jpush服务开启

3.用户注销退出登录(成功)后,调用stopPush -》确保关闭jpush服务,不再收到推送

为了更加安全,在调用stopPush之前,可以去用isPushStopped判断:如果已停止,可以不调用stopPush

如果正在运行,再调用stopPush去停止

4.用户再次登录(成功)后,调用resumePush -》确保jpush服务重新开启

另外,建议去确认自己所用的jpush的sdk是最新版本,如果不是最新,建议升级到最新。

jpush官网:

-》

当前是3.0.9:

Android错误代码返回,【已解决】JPUSH的回调返回错误代码6012相关推荐

  1. pycharm里有android虚拟设备吗,已解决!PyCharm打开一直出现Reloading generated skeletons问题...

    已解决!PyCharm打开一直出现Reloading generated skeletons问题 数据科学深度学习的同僚们对PyCharm真的是再熟悉不过了...虽然pycharm占用内存非常大,加载 ...

  2. android模拟器webservice,已解决:android 模拟器调用本地的webservice 引用不到

    背景,需要自己用 java 写一个 webservice, 然后写一个 android的客户端去调用它. 我这里折腾了2天,最后终于调成功了.以图为证. 要点: 1,  MyEclipse开发webs ...

  3. php返回mysql错误语句_[已解决]php查询mysql返回了错误的结果

    大约是不支持中文字符的原因:将mysql的所有属性都改成英文字符之后,使用mysql好了. 但是! 用mysqli写 还是会返回空(又测了下,密码框不输入或输入0都会得到登录成功的提示) 都明白了 r ...

  4. android批量安装,[已解决]分享Android apk 批量安装脚本

    @echo off setlocal enabledelayedexpansion title APKs ADB Install Tool v1.0.0 color 2f set adb=" ...

  5. android webview goback 刷新,解决webview调用goBack()返回上一页自动刷新闪白的情况

    问题是:重写了onKeyDown()方法使其goBack(),但是遇到的问题是,每次进入webview再次返回原始页面的时候,中间会有一个闪白的出现. 试了好多网上的方法,发现都是扯淡. 后来意识到, ...

  6. Microsoft Edge 和 Google Chrome更新后,出现错误代码:STATUS_STACK_BUFFER_OVERRUN,有效解决办法记录【已解决】

    Microsoft Edge 和 Google Chrome更新后,出现错误代码:STATUS_STACK_BUFFER_OVERRUN,有效解决办法记录[已解决] Google Chrome网页错误 ...

  7. cocos2d-x返回Android游戏黑屏解决办法

    返回Android游戏黑屏解决办法 这几天逛cocos2d-x.org论坛,发现cocos2d-x的作者放出来一个帖子,用来解决返回Android游戏加载资源时黑屏的问题.帖子过些日子估计就沉了,所以 ...

  8. 【已解决】Win10 更新失败的问题【错误代码为0x80070003】

    Win10 更新失败的问题[错误代码为"0x80070003"] 本文仅针对错误代码为 0x80070003 的情况 本文仅针对错误代码为 0x80070003 的情况 本文仅针对 ...

  9. 解决高德地图在线API不支持对应的方法回调返回结果的问题

    前阵子做了个基于高德在线地图分析业务数据的web应用,但是在使用其API的过程中发现一个很不友好的问题,那就是它不支持对应的方法回调返回结果(当时不支持,2014-12-18号发布的1.3.5版本更新 ...

最新文章

  1. MongoDB数据库(一:基本操作)
  2. Linux下mysqldump的使用
  3. string比较字符串某个指定的字符串
  4. 关于有源晶振倍频干扰的问题
  5. string中删除一个元素
  6. Spring 通过@Import实现Bean的注册
  7. 3dvary灯光材质为什么不亮_装修小白设计家里的灯光,知道这些参数就行了!
  8. JS之函数实际参数转换成数组的方法[].slice.call(arguments)
  9. 以后再想大数据杀熟就没那么容易了
  10. 百度云盘下载限速破解的方法
  11. 51单片机LCD1602程序
  12. 航信税控系统 - 安装分析(一)
  13. 深度估计 双目深度估计+单目深度估计 ONNX运行程序
  14. 老闪创业那些事儿(9)——雏鹰计划(上)
  15. python两点画线_在图像python matplotlib的两点之间画一条线
  16. 两代 Windows 性能大比拼!Win8 完胜 Win7
  17. 基于重心距离识别的蠓虫分类模型(唯一能看的只有代码)
  18. 【数学】泰勒公式推导(佩亚诺余项)
  19. 「业务架构」EA874:业务架构层
  20. tinymce自动实现斑马纹表格

热门文章

  1. 《C语言内核深度解析》——笔记及拓展(1)
  2. java如何判断一个点在一条线段上
  3. Chrome-谷歌浏览器多开教程
  4. 计算机二级access知识点6,2016计算机二级《Access》知识点
  5. 计算机系统导论与计算机导论,计算机系统导论之学习心得.doc
  6. (附源码)springboot动力电池数据管理系统 毕业设计 301559
  7. IBM WebBIOS配置
  8. linux挂载u盘并测试读写速度
  9. 安装APK报错解决方法
  10. win10服务器cpu占用过高,Win10 CPU占用率100%怎么办 Win10 CPU占用率过高解决方法