Closed clbDream closed 6 years ago
Same code, same action
`@RuntimePermissions class WriteActivity : BaseActivity() { /**
判断点击了哪个按钮 0 发布图文 1发布视频 */ private var SEND_TYPE: Int = 0
override fun intiLayout(): Int { return R.layout.activity_write }
override fun getPresenter() {
}
override fun initView() { }
override fun initData() { }
override fun onClick() { //发布文字 send_text.setOnClickListener { SEND_TYPE = 0 requestPermissionWithPermissionCheck() }
//发布视频
send_video.setOnClickListener {
SEND_TYPE = 1
requestPermissionWithPermissionCheck()
}
exit_write.setOnClickListener {
finish()
}
}
@NeedsPermission(Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR, Manifest.permission.CAMERA) fun requestPermission() { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { return } when (SEND_TYPE) { 0 -> { //发布图文 startActivity(Intent(this, SendTextActivity::class.java)) } 1 -> { //发布视频 startActivity(Intent(this, SendVideoActivity::class.java)) } else -> { } }
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array
@OnShowRationale(Manifest.permission.READ_CALENDAR, Manifest.permission.WRITECALENDAR, Manifest.permission.CAMERA) fun showReason(request: PermissionRequest) { AlertDialog.Builder(this) .setPositiveButton("去获取", { , -> request.proceed() }) .setNegativeButton("稍后再说", { , _ -> request.cancel() }) .setCancelable(false) .setMessage("发布信息需要添加图片和拍照的功能,否则无法正常使用发布功能哦!") .show() }
@OnPermissionDenied(Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR, Manifest.permission.CAMERA) fun deniedPermission() { toast("不打开相册和拍照功能无法发布信息哦!") }
@OnNeverAskAgain(Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR, Manifest.permission.CAMERA) fun refusePermission() { toast("您后续可以在设置中心打开相应的权限哦!") } }`
I'm really sorry that the problem has been solved. Some parts of my code have been written, so I'm sorry to bother you
👀 Sorry for the late how it's solved?
Yes, the permission I applied in the code was not written in the list file, now there is no problem