Android – java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10210 nor current process.. in HTC Phones only

androidexception

Error in HTC phones only works very much fine in samsung,lg, etc.

java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user
10210 nor current process has android.permission.READ_PHONE_STATE

Permission given in Manifest file

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

My code below

final TelephonyManager tm=(TelephonyManager)con.getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId(); 

This code is already tested in hundreds of Samsung, LG, Xiomi, Gionee, Xolo etc. phones and working very very much fine.

it only gives error in HTC Desire Series phones like,

PHONE_MODEL=HTC Desire 700 dual sim ANDROID_VERSION=4.1.2

I repeat it gives error only in htc phones, in other works fine.

Note :- Please understand and read question carefully before marking it as duplicate.

Best Answer

READ_PHONE_STATE is now considered a Dangerous Permissions and the user must give consent for you to use. It's not enough to include it in your Manifest.

Here's more information and examples on how to request permission.

http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous

http://developer.android.com/training/permissions/requesting.html

Related Topic