Commit 813a30dd by 刘鹏

feat: 权限申请更换方式

parent 7da8a914
package com.ydl.confide.home.modular.service
import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
......@@ -7,8 +8,7 @@ import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter
import com.hjq.permissions.OnPermissionCallback
import com.hjq.permissions.XXPermissions
import com.tbruyelle.rxpermissions2.RxPermissions
import com.ydl.audioim.IntentConstants
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.bean.ExpertInfoBean
......@@ -35,6 +35,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
/**
* Created by haorui on 2019-10-10.
* Des: 对应主项目中的WebServiceImpl
......@@ -188,27 +189,32 @@ class ConfideWebServiceImpl {
/**
* 检查权限
* */
@SuppressLint("CheckResult")
private fun checkPermission(id: Int, type: Int, activity: Activity, callType: String?) {
try {
//申请音频权限
XXPermissions.with(activity) // 申请单个权限
.permission(com.hjq.permissions.Permission.RECORD_AUDIO)
.request(object : OnPermissionCallback {
override fun onGranted(p0: MutableList<String>?, p1: Boolean) {
listenDial(id, type, activity,callType)
val rxPermissions = RxPermissions(activity)
rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO).subscribe { permission ->
when {
//权限已申请 进行通话
permission.granted -> {
listenDial(id, type, activity, callType)
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "请求音频权限通过")
}
override fun onDenied(permissions: MutableList<String>?, never: Boolean) {
listenDial(id, type, activity,"1");
// 拒绝权限操作发送给服务端
//权限未申请 重新申请
permission.shouldShowRequestPermissionRationale -> {
checkPermission(id, type, activity, callType)
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "拒绝请求音频权限")
.sendRichLog(AliYunLogConfig.AGORA, "权限未申请 重新申请")
}
//跳转设置界面
else -> {
listenDial(id, type, activity, "1")
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "权限拒绝 转axb")
}
}
}
})
} catch (e: Exception) {
listenDial(id, type, activity,"1");
AliYunRichLogsHelper.getInstance()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment