作者 liyan

增加打电话权限和功能

... ... @@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:name=".base.view.BaseApplication"
... ...
package com.br_technology.securitytrain_master.ui.mine.activity
import android.Manifest
import android.content.Intent
import android.net.Uri
import com.br_technology.securitytrain_master.databinding.ActivityServiceBinding
import com.br_technology.securitytrain_master.ext.initPermissions
import com.br_technology.securitytrain_master.ui.home.viewmodel.ServiceViewModel
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
... ... @@ -16,7 +20,21 @@ class ServiceActivity :
binding.apply {
// 拨打电话
call.setOnClickListener { }
call.setOnClickListener {
initPermissions(Manifest.permission.CALL_PHONE,
onGranted = {
val intent = Intent()
intent.setAction(Intent.ACTION_CALL)
intent.setData(Uri.parse("tel:" + mobile.text.toString().trim()))
startActivity(intent)
},
onDenied = {
},
onDeniedNever = {
//跳转到设置页面
})
}
// 下载二维码
download.setOnClickListener { }
}
... ...