FATAL EXCEPTION: IntentService[]
Process: com.frenzin.alert, PID: 5892
java.lang.SecurityException: getDeviceId: Neither user 10240 nor current process has android.permission.READ_PHONE_STATE.
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at com.android.internal.telephony.ITelephony$Stub$Proxy.getDeviceId(ITelephony.java:4207)
at android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:706)
at com.frenzin.alert.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:44)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Asked
Active
Viewed 106 times
-3

Koby Douek
- 16,156
- 19
- 74
- 103

Bhargav Thanki
- 4,924
- 2
- 37
- 43
-
2Possible duplicate of [Android marshmallow request permission?](http://stackoverflow.com/questions/33666071/android-marshmallow-request-permission) – RoShan Shan Mar 29 '17 at 07:21
-
1read this first https://developer.android.com/training/permissions/requesting.html – Jenis Kasundra Mar 29 '17 at 07:23
2 Answers
1
Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. The user can grant or deny each permission, and the app can continue to run with limited capabilities even if the user denies a permission request.
To request permission in runtime, go to https://developer.android.com/training/permissions/requesting.html

Fathima km
- 2,539
- 3
- 18
- 26
0
Add runtime permission for access
Add library:
compile 'pub.devrel:easypermissions:0.2.1'
private String[] phonePermissions = {Manifest.permission.READ_PHONE_STATE};
if (EasyPermissions.hasPermissions(this, phonePermissions)) {
//success
} else {
EasyPermissions.requestPermissions(this, "Access for Read Phone",
101, phonePermissions);
}

Jd Prajapati
- 1,953
- 13
- 24