From 3408b10a3466f2db3f81e5c484142e3c180d36ac Mon Sep 17 00:00:00 2001 From: lmw <125975490@qq.com> Date: 星期五, 12 五月 2023 11:24:02 +0800 Subject: [PATCH] 定位权限说明弹窗 --- app/src/main/java/com/fuban/driver/base/MyApplication.kt | 76 +++++++------------------------------ 1 files changed, 15 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/com/fuban/driver/base/MyApplication.kt b/app/src/main/java/com/fuban/driver/base/MyApplication.kt index 907dc61..83b5079 100644 --- a/app/src/main/java/com/fuban/driver/base/MyApplication.kt +++ b/app/src/main/java/com/fuban/driver/base/MyApplication.kt @@ -6,8 +6,6 @@ import android.os.* import android.util.Log import androidx.annotation.RequiresApi -import cn.jpush.android.api.JPushInterface -import cn.jpush.android.api.TagAliasCallback import cn.sinata.rxnetty.NettyClient import cn.sinata.xldutils.BaseApplication import cn.sinata.xldutils.utils.sysErr @@ -33,7 +31,6 @@ import com.fuban.driver.utils.Cache.CacheUtil import com.fuban.driver.utils.LogUtils import com.google.gson.Gson -import com.tencent.bugly.crashreport.CrashReport import com.umeng.commonsdk.UMConfigure import com.umeng.socialize.PlatformConfig import com.xuexiang.xui.XUI @@ -68,6 +65,17 @@ handleSSLHandshake() //如果是主进程 XUI.init(this) + registerActivityLifecycleCallbacks(this) +// CrashReport.initCrashReport(getApplicationContext(), "444bb776ed", false); + LogUtils.OpenLog(true) + initUpPoint() + initSocket() + } + + /** + * 延迟初始化,在用户同意隐私协议后进行 + */ + fun initSdk(){ UMConfigure.init( this, "640ae80cba6a5259c41ab641", @@ -75,69 +83,13 @@ UMConfigure.DEVICE_TYPE_PHONE, "" ) - registerActivityLifecycleCallbacks(this) PlatformConfig.setWeixin("wx19a713b4943f9568", "5d4ca951a855b1e2c86a844cd42fd133") PlatformConfig.setQQZone("1112151767", "5viZ7mQkNkYtUr7b") //qq互联 -// CrashReport.initCrashReport(getApplicationContext(), "444bb776ed", false); - LogUtils.OpenLog(true) - initUpPoint() - initSocket() - JPushInterface.setDebugMode(true) - JPushInterface.init(this) - setAlisa() } - public fun setAlisa() { - if (CacheKey.getUserId().isNotEmpty()) { - var alisa = "DRIVER" + CacheKey.getUserId() - sysErr(alisa) - mHandler.sendMessage(mHandler.obtainMessage(MSG_SET_ALIAS, alisa)) - } - } - private val MSG_SET_ALIAS = 1001 - private val mHandler: Handler = object : Handler() { - override fun handleMessage(msg: Message) { - super.handleMessage(msg) - when (msg.what) { - MSG_SET_ALIAS -> { - Log.d(TAG, "Set alias in handler.") - // 调用 JPush 接口来设置别名。 - JPushInterface.setAliasAndTags( - applicationContext, - msg.obj as String, - null, - mAliasCallback - ) - } - else -> Log.i(TAG, "Unhandled msg - " + msg.what) - } - } - } - private val mAliasCallback = - TagAliasCallback { code, alias, tags -> - val logs: String - when (code) { - 0 -> { - logs = "Set tag and alias success" - Log.i("TAG", logs) - } - 6002 -> { - logs = "Failed to set alias and tags due to timeout. Try again after 60s." - Log.i("TAG", logs) - // 延迟 60 秒来调用 Handler 设置别名 - var alisa = "DRIVER" + CacheKey.getUserId() - Handler().postDelayed({ - JPushInterface.setAliasAndTags(this, alisa, null, null) - }, 60 * 1000) - } - else -> { - logs = "Failed with errorCode = $code" - Log.e("TAG", logs) - } - } - } + private fun initSocket() { NettyClient.getInstance().init(this, Api.SOCKET_SERVER, Api.SOCKET_PORT, true) @@ -401,6 +353,7 @@ companion object { private const val TAG = "MyApplication" + var canPlayVoice = false //进入主页才可以播放语言通知 protected var mTtsManager: TTSController? = null public var isLogin: Boolean = true @@ -502,7 +455,8 @@ showNum-- Handler(Looper.getMainLooper()).postDelayed({ if (showNum == 0) { - getTTsManager().setVideoText("福伴出行司机已置于后台,可能会导致听单异常,里程计费差异,请勿切换。") + if (canPlayVoice) + getTTsManager().setVideoText("福伴司机已置于后台,可能会导致听单异常,里程计费差异,请勿切换。") } }, 600) -- Gitblit v1.7.1