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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -