How to give Runtime Permission for READ_PHONE_STATE in Android

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

I need to get IMEI number for an android mobile. So i added READ_PHONE_STATE in visualizer settings, But i am unable to get the runtime perimission alert in >=6.0 version for android mobile.

Hi,

With this below line, you should get runtime permission alert and after accepting it, IMEI number. Please let me once you have tried.

kony.os.deviceInfo().uid

Regards

Hi,

Please checkout kony API for your task .

http://docs.kony.com/konylibrary/visualizer/viz_api_dev_guide/Default.htm#runtime_permissions.htm

Hi,

I saw what you sent Every thing working like kony.os.RESOURCE LOCATION,kony.os.RESOURCE_CAMERA,kony.os.RESOURCE_PHOTO_GALLERY,kony.os.RESOURCE_CONTACTS, kony.os.RESOURCE_CALENDAR,kony.os.RESOURCE_EXTERNAL_STORAGE these are all working fine. But I need READ_PHONE_STATE. it not able to enable the runtime permission please help me this.

Hi,

I tried kony.os.deviceInfo().uid it's getting only one IMEI number but I using dual sim and I want to validate both the IMEI number in validation time and I tried kony.os.getDeviceId(0),and kony.os.getDeviceID(1) it's getting two IMEI number if device has dual sim and when I'm going to test in 4.4 device version that time single sim mode it's not working.

Hi,

Write FFI for Android with the code below .

Request Permission :

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 1);

Check Permission :

if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE)

!= PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_PHONE_STATE}, 1);

} else {

//call your method

}

https://chantisandroid.blogspot.com/2017/05/android-60marshmallow-runtime.html

The READ_PHONE_STATE permission requesting doesn't work in runtime if you're targeting your SDK to API26. Does anyone has a work around for this ?

Hi,

Use kony.application.requestPermission() api to get runtime permission alert for READ_PHONE_STATE permission.

Sample Code snippet:

kony.application.requestPermission("android.permission.READ_PHONE_STATE", permissionStatusCallback());

function permissionStatusCallback(response) {

if (response.status == kony.application.PERMISSION_GRANTED) {

} else if (response.status == kony.application.PERMISSION_DENIED) {

}

}

Please refer below document link :

http://docs.kony.com/konylibrary/visualizer/viz_api_dev_guide/Default.htm#kony.application_functions_runtimepermissionsapi.htm

Regards