How can my app change the network to another WiFi in android 6.0 mobilephone? -
process below (test on platform android api level =23 android 6.0 mobilephone):
in app :
mwifimanager.addnetwork(wcg); boolean b = mwifimanager.enablenetwork(wcgid, true);
but b return false;
log print:
not authorized remove network ...... not authorized update network
then try method in wifimanager(marked @hide):
connect(int networkid, actionlistener listener)
by reflectmethod , result failed . print as:
java.lang.reflect.invocationtargetexception
in lollipop should try checking active ssid same otherwise disable network.
int netid = mwifimanager.addnetwork(conf); if (netid == -1) { librelogger.d(this, "failed set settings " + mnetworkssidtoconnect); final list<wificonfiguration> mwificonfiguration = mwifimanager.getconfigurednetworks(); (int = 0; < mwificonfiguration.size(); i++) { string configssid = mwificonfiguration.get(i).ssid; librelogger.d(this, "config ssid" + configssid + "active ssid" + conf.ssid); netid = mwificonfiguration.get(i).networkid; if (configssid.equals(conf.ssid)) { librelogger.d(this, "network id" + netid); break; } else { **/*if ssid not same disable other network here */** mwifimanager.disablenetwork(netid); } } }
Comments
Post a Comment