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/ui/main/MainActivity.kt | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/fuban/driver/ui/main/MainActivity.kt b/app/src/main/java/com/fuban/driver/ui/main/MainActivity.kt index f7814da..5566e4b 100644 --- a/app/src/main/java/com/fuban/driver/ui/main/MainActivity.kt +++ b/app/src/main/java/com/fuban/driver/ui/main/MainActivity.kt @@ -56,6 +56,7 @@ } override fun initView() { + MyApplication.canPlayVoice = true // var packageName = "com.android.providers.downloads"; // var intent = Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); // intent.setData(Uri.parse("package:" + packageName)); @@ -63,13 +64,18 @@ if (CacheKey.getKeyStr(Const.REFUSE_LOCATION).isNotEmpty()&&!RxPermissions(this).isGranted(Manifest.permission.ACCESS_FINE_LOCATION)){ toast("没有定位权限,您将无法收到新订单推送") }else{ - val subscribe = - RxPermissions(this).request(Manifest.permission.ACCESS_FINE_LOCATION).subscribe { - if (!it){ - toast("没有定位权限,您将无法收到新订单推送") - CacheKey.putKeyStr(Const.REFUSE_LOCATION,"1") - } + if (!RxPermissions(this).isGranted(Manifest.permission.ACCESS_FINE_LOCATION)){ + DialogUtil.getDelAndSureDialog(this,"去授权","否","《福伴司机》需要获取您的当前位置信息,用于查询当前城市是否开通服务,我们会将您的位置实时上传至后端为您匹配和推送附近订单。如果拒绝定位权限,您将无法正常接单。",{ + }){ + val subscribe = + RxPermissions(this).request(Manifest.permission.ACCESS_FINE_LOCATION).subscribe { + if (!it){ + toast("没有定位权限,您将无法收到新订单推送") + CacheKey.putKeyStr(Const.REFUSE_LOCATION,"1") + } + } } + } } setTitleText("福伴司机") tv_Left.setDrawableLeft(R.mipmap.icon_nav_user) @@ -330,4 +336,8 @@ } } + override fun onDestroy() { + super.onDestroy() + MyApplication.canPlayVoice = false + } } \ No newline at end of file -- Gitblit v1.7.1