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):

  1. 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   
  2. 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

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

java - What is the equivalent of @Value in CDI world? -