Lilly
06/03/2022, 12:34 AMAdd permission check
in composables?:
Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityExceptionWith Android 12 this shit becomes really confusing. Anything that is not like:
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.BLUETOOTH_CONNECT
) != PackageManager.PERMISSION_GRANTED
) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return
}
val deviceName: String? = sharedPresenter.connectedDevice?.name // no warning
will be reported as if the permission has never been granted, which is technically wrong. But the example above is no real world use case and also verbose and leads to duplicated code. That's why accompanist has its rememberPermissionState
API. But using this API does not prevent the warning.Joseph Hawkes-Cates
06/03/2022, 4:30 AMColton Idle
06/03/2022, 10:31 AMLilly
06/03/2022, 1:10 PM@Supress("MissingPermission")
annotations everywhere...Colton Idle
06/03/2022, 2:41 PM