How to check permission in fragment

前端 未结 9 1966
执念已碎
执念已碎 2020-12-01 03:49

I want to check a permission inside a fragment.

my code:

        // Here, thisActivity is the current activity
        if (ContextCompat.checkSelfPe         


        
9条回答
  •  误落风尘
    2020-12-01 04:36

    Using Kotlin, you call requestPermissions(arrayOf(Manifest.permission.THE_PERMISSION_CODE_YOU_WANT), PERMISSION_REQUEST_CODE) and add the following override to your fragment

    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray): Unit {
    
    }
    

提交回复
热议问题