Raluca
Raluca

Reputation: 51

SecurityException when calling getNetworkCapabilities on Android 11

I'm getting this exception even if I have ACCESS_NETWORK_STATE permission granted.

 Caused by: java.lang.SecurityException:
at android.os.Parcel.createExceptionOrNull (Parcel.java:2385)
at android.os.Parcel.createException (Parcel.java:2369)
at android.os.Parcel.readException (Parcel.java:2352)
at android.os.Parcel.readException (Parcel.java:2294)
at android.net.IConnectivityManager$Stub$Proxy.getNetworkCapabilities (IConnectivityManager.java:3347)
at android.net.ConnectivityManager.getNetworkCapabilities (ConnectivityManager.java:1549)

How to avoid it?

Upvotes: 0

Views: 1347

Answers (1)

zack
zack

Reputation: 3198

It's a known issue: https://issuetracker.google.com/issues/175055271?pli=1

You could wrap the call in a try/catch to handle the exception, and at least avoid the crash.

Upvotes: 1

Related Questions