My instant app crash when i run script “WifiManager.isWifiEnable”
Caused by: java.lang.SecurityException: Method class android.net.wifi.IWifiManager$Stub$Proxy.getWifiEnabledState[] not available to instant apps
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.readReply(MethodInvocationProxy.java:238)
at com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.invoke(MethodInvocationProxy.java:472)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy15.getWifiEnabledState(Unknown Source)
at android.net.wifi.WifiManager.getWifiState(WifiManager.java:1459)
at android.net.wifi.WifiManager.isWifiEnabled(WifiManager.java:1471)
WifiManager
This class provides the primary API for managing all aspects of Wi-Fi connectivity.
It defines the names of various Intent actions that are broadcast upon any sort of change in Wi-Fi state.
Instances of this class must be obtained using Context.getSystemService(Class)
with the argument WifiManager.class
or Context.getSystemService(String)
with the argument Context.WIFI_SERVICE
.
setWifiEnabled
require CHANGE_WIFI_STATE
This is the API to use when performing Wi-Fi specific operations. To perform operations that pertain to network connectivity at an abstract level, use ConnectivityManager
.
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
You will need:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
We can use only API methods that limited With Instant permissions