Android Question Error getDataNetworkTypeForSubscriber

guenneguez_t

Member
Licensed User
Longtime User
Hi,

I developpe an APP and it work fine on my device, but not on an other that I can't see.
The error is :
java.lang.SecurityException: getDataNetworkTypeForSubscriber

I don't know wy I have this error. It seem's that android.permission.READ_PHONE_STATE is require but I don't know what function require this right.
Befor add this right in the Manifeste, I want to know why ;-)

Thanks for help
Thomas
 

drgottjr

Expert
Licensed User
Longtime User
getDataNetworkTypeForSubscriber requires android.permission.READ_PHONE_STATE in the manifest for
apps targeting android 11 (sdk30).
in addition, READ_PHONE_STATE is considered a "dangerous" permission, so you will have to prompt the
user for her permission. this is a so-called runtime permission, and, normally, is only required the first time the
app is run. have you used runtime permissions? many examples here, easy to use.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
somewhere in your app somebody runs the getDataNetworkTypeForSubscriber method. without android.permission.READ_PHONE_STATE in your manifest, the exception is thrown. you can argue with this if you like. i suggest you add the permission and handle it at runtime and see if the exception goes away. or find out where the method is run and don't use it or don't use the method that runs it. good luck.
 
Upvote 0

guenneguez_t

Member
Licensed User
Longtime User
Hello
Thanks for reply.
I remove the call to the Pone.GetNetworkType , but it will be greate to display this information in the doc.

Thanks
Thomas
 
Upvote 0
Top