Friday, 15 September 2017

Android READ_PHONE_STATE runtime permission asks to make and manage phone calls

Answer


Answer




In app I want to get unique phone id via TelephonyManager.getDeviceId(). To use this I need this permission READ_PHONE_STATE. Problem is with runtime permission on Android 6. In runtime permission popup dialogue, it asks to grant permission "To make and manage phone calls" which can scary users from using app. What can be done? Or can I get any other unique identifier for device without using such big permission?



TelephonyManager TM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

String deviceId = TM.getDeviceId();


Answer



I am using this as a unique device identifier in my app and i don't need any run time permission.



String android_id = Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.Secure.ANDROID_ID);


or You can use this



 String uuid = UUID.randomUUID().toString();


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...