Код: Выделить всё
int android.content.Context.checkPermission(java.lang.String, int, int)' on a null object referenceTest_class.kt
Код: Выделить всё
class Test_class() :AppCompatActivity() {
fun checkpermissions(context: Context) {
val permissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
){ isGranted ->
if (isGranted) {
Toast.makeText(context,"Permission accepted", Toast.LENGTH_SHORT).show()
}
else {
Toast.makeText(context,"Permission denied", Toast.LENGTH_SHORT).show()
}
}
val perm = Manifest.permission.CALL_PHONE
permissionLauncher.launch(perm)
Код: Выделить всё
(..)
pbtn.setOnClickListener {
val ex = Test_class()
ex.checkpermissions(applicationContext)
}
(..)
Заранее спасибо
п>
Подробнее здесь: https://stackoverflow.com/questions/790 ... ity-in-kot
Мобильная версия