I was creating an app that will create and enable wifi hotspot of my mobile using the given credential
public static boolean setHotspotName(String ssid, String pass, Context context) {
try {
WifiManager wifiManager = (WifiManager) context.getSystemService(context.WIFI_SERVICE);
Method getConfigMethod = wifiManager.getClass().getMethod("getWifiApConfiguration");
WifiConfiguration wifiConfig = (WifiConfiguration) getConfigMethod.invoke(wifiManager);
wifiConfig.SSID = ssid;
Method setConfigMethod = wifiManager.getClass().getMethod("setWifiApConfiguration", WifiConfiguration.class);
setConfigMethod.invoke(wifiManager, wifiConfig);
return true;
}
catch (Exception e) {
e.printStackTrace();
return false;
}
}
getting this error
W/System.err: Caused by: java.lang.SecurityException: App not allowed to read
or update stored WiFi Ap config (uid = 10492)