android 初始化如何判断初始化是否成功


(小股东) #106

我如何 判断一个设备到底在线不在线呢?


(小股东) #107

上课的都是学生 一些不想上课的学生巴不得收不到老师的 消息呢


#108

:joy:什么判断是不是在线,有regId的应该就没问题,注册成功不是有广播吗


(小股东) #109

恩 那就是通过获取regid 来判断是否注册成功??


#110

你看一下demo MyReceiver里面,第一次注册成功会调到onReceive ACTION_REGISTRATION_ID


#111

可以通过regId来判断是否注册成功,但是无法确认时机,所以还是要看广播里面的回调


(小股东) #112

也就是说 广播onReceive ACTION_REGISTRATION_ID 只要回掉有 regid 就说明注册成功了 是吧,而且他只返回一次 ,我现在应该在什么时候 去给服务器发送 log信息呢 在什么时候去执行发送? 还有我log用JIGUANG-JPush,JIGUANG-JCore 这两个筛选到底行不行啊


#113

日志筛选没有问题,但是这个日志发送时机确实不好选,或者你可以在延迟一段时间过后,然后通过JPushInterface.getConnectionState 来获取长连接的状态,如果没能成功建立链接,你就可以把日志上报


(小股东) #114

也就是说 我可以通过 获取长连接状态 来判断发送不发送 是吧 ,那通过regid来判断发送不发送可以吗


(12) #115

可以啊,我上面不是跟你说了么,获取到了regIstrationID就是注册成功的,取了多次都取不到就是没成功,可以选择上报 log


#116

你就通过长连接状态来吧,这样一些注册成功不能收到推送的情况也可以收集到


(12) #117

1 个帖子被分离到了新主题:关于Android 的tag的问题


(小股东) #119

通过 JPushInterface.getConnectionState(MainActivity.this) ,这个长连接判断,是否是如果长连接没有连接上,返回的是false, 那么 registid 是不是也是空的???


(12) #120

这二者并不是同一个概念,获取registrationID请用 getregistrationID 的方法


(小股东) #121

我知道 我的意思是他们之间有没有什么联系 如果 长连接没有连接上,那么registreid 是不是也是空?


(小股东) #122

我现在在找什么时候应该上报 log给服务器 当时你们两个是这么说的,

你说是 用registerid 你的那个同事说用 长连接状态判断 上传log时机,,,,,应该是什么时候上传log????????


(12) #123

1、长连接没有连上,代表当前收不到消息,即便是初始化成功的设备也会出现长连接断开的情况,譬如网络断开的时候。

他这里也说明了,集成成功,但收不到消息,一般就是由于长连接断开了。

2、[quote=“Lris, post:115, topic:26266, full:true”]
获取到了regIstrationID就是注册成功的,取了多次都取不到就是没成功,可以选择上报 log
[/quote]

我这里是仅仅针对你的初始化无法成功来说的,你如果只要判断为什么初始化不成功,取不到registrationID,就根据registrationID 来判断


(小股东) #124

那么 长连接没有连上的情况 包不包括 初始化不成功 或者 registerid 为空 的情况???


#125

包括,不注册、不初始化,是不可能有长连接的


(小股东) #126
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
05-25 10:43:36.784 D/JIGUANG-JPush(31924): [JPushInterface] action:init - sdkVersion:3.1.1, buildId:396
05-25 10:43:36.804 D/JIGUANG-JCore(31924): [JCoreGlobal] metadata: appKey - 757bf908e1a2bcd0a064aacf
05-25 10:43:36.804 D/JIGUANG-JCore(31924): [JCoreGlobal] metadata: channel - developer-default
05-25 10:43:36.814 D/JIGUANG-JCore(31924): [AndroidUtil] action:checkValidManifest
05-25 10:43:36.824 D/JIGUANG-JCore(31924): [JCoreServiceUtils] set Push/Alarm Receiver enabled
05-25 10:43:36.854 D/JIGUANG-JCore(31924): [JCoreGlobal] action:init - sdkVersion:1.1.9, buildId:172
05-25 10:43:36.904 D/JIGUANG-JPush(31924): [AndroidUtil] action:checkValidManifest
05-25 10:43:37.004 I/JIGUANG-JPush(31924): [PluginPlatformsInterface] whichPlatform - 0
05-25 10:43:37.004 I/JIGUANG-JPush(31924): [PluginPlatformsInterface] isIntegrateFCM -false
05-25 10:43:37.134 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.run.action cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.134 D/JIGUANG-JCore(31924): [ARunAction]  pkg:com.aixuetang.future
05-25 10:43:37.134 D/JIGUANG-JCore(31924): [ARunAction] Bundle[{action=cn.jpush.android.intent.REPORT, report.extra.info=, report=crash_log, sdktype=JCORE}]
05-25 10:43:37.144 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.intent.INIT cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.144 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.run.action cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.144 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.intent.INIT cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.154 D/JIGUANG-JCore(31924): [JiguangTcpManager] Action - restartNetworkingClient, pid:31924
05-25 10:43:37.154 I/JIGUANG-JCore(31924): [NetworkingClient] Begin to run in ConnectingThread - id:5640
05-25 10:43:37.154 D/JIGUANG-JCore(31924): [JiguangTcpManager] Action - restartNetworkingClient, pid:31924
05-25 10:43:37.164 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.run.action cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.174 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.intent.INIT cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.174 D/JIGUANG-JCore(31924): [JiguangTcpManager] isRunning:true
05-25 10:43:37.174 D/JIGUANG-JCore(31924): [ARunAction]  pkg:com.aixuetang.future
05-25 10:43:37.184 D/JIGUANG-JCore(31924): [ARunAction] Bundle[{action=cn.jpush.android.intent.REPORT, report.extra.info=, report=crash_log, sdktype=JCORE}]
05-25 10:43:37.184 D/JIGUANG-JCore(31924): [JiguangTcpManager] Action - restartNetworkingClient, pid:31924
05-25 10:43:37.194 D/JIGUANG-JCore(31924): [JiguangTcpManager] isRunning:true
05-25 10:43:37.194 D/JIGUANG-JCore(31924): [ARunAction]  pkg:com.aixuetang.future
05-25 10:43:37.194 D/JIGUANG-JCore(31924): [ARunAction] Bundle[{action=cn.jpush.android.intent.REPORT, report.extra.info=, report=crash_log, sdktype=JCORE}]
05-25 10:43:37.204 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.intent.RTC cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.224 D/JIGUANG-JCore(31924): [JiguangTcpManager] Action - restartNetworkingClient, pid:31924
05-25 10:43:37.224 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.cn.jpush.android.intent.check.notification.state cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.224 D/JIGUANG-JCore(31924): [PushReceiver] onReceive - android.net.conn.CONNECTIVITY_CHANGE
05-25 10:43:37.234 D/JIGUANG-JCore(31924): [JiguangTcpManager] isRunning:true
05-25 10:43:37.244 D/JIGUANG-JPush(31924): [PushReceiverCore] onReceive - android.net.conn.CONNECTIVITY_CHANGE
05-25 10:43:37.244 D/JIGUANG-JCore(31924): [PushService] onStartCommand - intent:Intent { act=com.aixuetang.future.intent.CONNECTIVITY_CHANGE cmp=com.aixuetang.future/cn.jpush.android.service.PushService (has extras) }, pkg:com.aixuetang.future, connection:0
05-25 10:43:37.264 D/JIGUANG-JCore(31924): [JiguangTcpManager] Action - restartNetworkingClient, pid:31924
05-25 10:43:37.274 D/JIGUANG-JCore(31924): [JiguangTcpManager] isRunning:true
05-25 10:43:37.314 D/JIGUANG-JCore(31924): [SisPolicy] Open connection with main - ip:103.229.215.26, port:7002
05-25 10:43:37.504 D/JIGUANG-JCore(31924): [HttpHelper] status code:200
05-25 10:43:37.614 I/JIGUANG-JCore(31924): [SisPolicy] Succeed to open connection - ip:103.229.215.26, port:7002
05-25 10:43:37.664 I/JIGUANG-JCore(31924): [ConnectingHelper] Login with - juid:8108746337, appKey:757bf908e1a2bcd0a064aacf, sdkVersion:65801, pushVersion:196865, analyticsVersion:0 ,shareVersion:0, pluginPlatformType:0
05-25 10:43:37.804 I/JIGUANG-JCore(31924): [ConnectingHelper] Login succeed - sid:6190, serverTime;1527216216000
05-25 10:43:37.804 D/JIGUANG-JCore(31924): [ConnectingHelper] Action - sendServerTimer
05-25 10:43:37.824 D/JIGUANG-JCore(31755): [HttpHelper] status code:200
05-25 10:43:37.984 D/JIGUANG-JCore(31924): [JiguangTcpManager] Action - onLoggedIn - connection:5640
05-25 10:43:37.984 D/JIGUANG-JCore(31924): [ConnectingHelper] Action - sendConnectionChanged
05-25 10:43:37.994 I/JIGUANG-JCore(31924): [ReportHelper] periodTasks...
05-25 10:43:37.994 D/JIGUANG-JCore(31924): [NetworkingClient] Network listening...
05-25 10:43:40.314 D/JIGUANG-JCore(31924): [JiguangTcpManager] Already logged in. Give up to restart.
05-25 10:43:53.004 D/JIGUANG-JCore(31924): [JiguangTcpManager] Send heart beat
05-25 10:43:53.074 D/JIGUANG-JCore(31924): [NetworkingClient] Received bytes - len:36, connection:5640, pkg:com.aixuetang.future
05-25 10:43:53.074 D/JIGUANG-JCore(31924): [NetworkingClient] Network listening...
05-25 10:43:53.084 D/JIGUANG-JCore(31924): [JiguangTcpManager] Action - onHeartbeatSucceed - connection:5640
05-25 10:43:59.494 D/JIGUANG-JPush(31924): [JPushDataAction] Action - onActionRun
05-25 10:43:59.494 D/JIGUANG-JPush(31924): [PushServiceCore] bundle:Bundle[{action=com.aixuetang.future.intent.ALIAS_TAGS, proto_type=2, seq_id=25407, tags=null, alias=211003575, protoaction_type=2, sdktype=JPUSH}]
05-25 10:43:59.494 D/JIGUANG-JPush(31924): [PushServiceCore] Action - handleServiceAction - action:com.aixuetang.future.intent.ALIAS_TAGS
05-25 10:43:59.514 D/JIGUANG-JPush(31924): [TagAliasHelper] tagalias:[TagaliasRequest] - appKey:757bf908e1a2bcd0a064aacf, action:{"op":"set","alias":"211003575","platform":"a"} - [Request] - [JHead] - len:0, version:1, command:29, rid:25407, sid:0, juid:0
05-25 10:43:59.514 D/JIGUANG-JPush(31924): [JPushRequestHelper] Action - sendJPushRequest, timeout:20000, threadId:5636
05-25 10:43:59.544 D/JIGUANG-JCore(31924): [RequestCacheManager] Action - sendRequestInternal - connection:5640, timeout:20000,sdkType:JPUSH, threadId:5631
05-25 10:43:59.734 D/JIGUANG-JPush(31924): [JPushDataAction] response:[TagaliasResponse] - action:{"code":0} - JResponse{code=0}
05-25 10:43:59.734 D/JIGUANG-JCore(31924): [NetworkingClient] Received bytes - len:36, connection:5640, pkg:com.aixuetang.future
05-25 10:43:59.734 D/JIGUANG-JCore(31924): [NetworkingClient] Network listening...

您好 这是我 登录成功时候的日志 我自己收集的,您看一下全不全