From bd6a8872438a35d47821c5d5da7fe149e5fed3ab Mon Sep 17 00:00:00 2001
From: lmw <125975490@qq.com>
Date: 星期三, 21 六月 2023 09:53:36 +0800
Subject: [PATCH] 处理收不到广播

---
 app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt |   72 +++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt b/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt
index baad814..54057fb 100644
--- a/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt
+++ b/app/src/main/java/com/okgoincar/base/MainBroadCastReceiver.kt
@@ -5,6 +5,7 @@
 import android.content.Intent
 import android.os.Handler
 import android.os.Looper
+import android.util.Log
 import cn.sinata.rxnetty.netStatus.NetUtils
 import cn.sinata.xldutils.utils.toast
 import com.google.gson.Gson
@@ -23,40 +24,43 @@
 
 class MainBroadCastReceiver : BroadcastReceiver() {
     override fun onReceive(contexts: Context?, intent: Intent?) {
-//        if (intent == null) {
-//            toast("内容获取为空,广播接收消息错误")
-//            return
-//        }
-//        try {
-//            Handler(Looper.getMainLooper()).post {
-//                val b = intent.getBooleanExtra("isLogin", true)
-//                if (!b) {
-//                    loginOut(contexts)
-//                    CacheUtil.get().clear()
-//                    EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
-//                } else {
-//                    if (getToken().isNullOrEmpty()) {
-//                        Handler(Looper.getMainLooper()).post {
-////                            toast("开始登录")
-//                        }
-//                        var driverCertificate = intent.getStringExtra("driverCertificate")
-//                        if (driverCertificate == null) {
-////                            toast("身份证获取失败")
-//                        } else {
-//                            if (contexts == null) {
-////                                toast("上下文为空,使用全局跳转")
-//                                toLoginActivity(MyApplication.getInstance(), driverCertificate)
-//                            } else {
-//                                toLoginActivity(MyApplication.getInstance(), driverCertificate)
-//                            }
-//                        }
-//
-//                    }
-//                }
-//            }
-//        } catch (e: Exception) {
-//
-//        }
+        MyApplication.upLog("收到广播,Action:${intent?.action}")
+        Log.e("MoneyBroadCastReceiver","收到广播,Action:${intent?.action}")
+        if (intent == null) {
+            toast("内容获取为空,广播接收消息错误")
+            return
+        }
+        try {
+            Handler(Looper.getMainLooper()).post {
+                val b = intent.getBooleanExtra("isLogin", true)
+                if (!b) {
+                    loginOut(contexts)
+                    CacheUtil.get().clear()
+                    EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
+                } else {
+                    if (getToken().isNullOrEmpty()) {
+                        Handler(Looper.getMainLooper()).post {
+//                            toast("开始登录")
+                        }
+                        var driverCertificate = intent.getStringExtra("driverCertificate")
+                        if (driverCertificate == null) {
+//                            toast("身份证获取失败")
+                        } else {
+                            MyApplication.upLog("广播参数:driverCertificate:${driverCertificate},开始登录")
+                            if (contexts == null) {
+//                                toast("上下文为空,使用全局跳转")
+                                toLoginActivity(MyApplication.getInstance(), driverCertificate)
+                            } else {
+                                toLoginActivity(MyApplication.getInstance(), driverCertificate)
+                            }
+                        }
+
+                    }
+                }
+            }
+        } catch (e: Exception) {
+
+        }
 
     }
 

--
Gitblit v1.7.1