Search code examples
androidandroid-permissions

Android READ_PHONE_STATE runtime permission asks to make and manage phone calls


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();

Solution

  • 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();