Muhammed Almaz Muhammed Almaz - 8 months ago 79
Android Question

Android permission issue

This code worked my phone.But it didnt worked from my friend phone. I have permission too . I get This error ;

Neither user 10109 nor current process has android.permission.READ_PHONE_STATE.

Permission ;

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

This is my Code ;

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
IMEI= telephonyManager.getDeviceId();

I Solved it From this code.

if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { return ; }


This is probably due to your friend running on Android 6.0 (API level 23). You need to add permissions at Runtime as well as the ones in the Manifest.

Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. This approach streamlines the app install process, since the user does not need to grant permissions when they install or update the app. It also gives the user more control over the app's functionality; for example, a user could choose to give a camera app access to the camera but not to the device location. The user can revoke the permissions at any time, by going to the app's Settings screen.

Refer here for more information. Maybe take a look at this question to see how to implement runtime permissions, although it's explained in the first link as well.