i've written application connect android devices our company's various wireless networks. intended run once, when device unboxed , set rest of our application suite.
the problem sometimes, device forget networks without being told so. have not been able reproduce this, unfortunately. i'm hoping i've missed api call android gurus here can me find.
the code follows run-once wireless initialization app, network names , keys changed. can see i'm doing incorrectly here?
edit: device have observed behavior on lg ally. i'm hoping it's bug own code, that's i'm starting.
@override public void oncreate(bundle savedinstancestate) { wificonfiguration n1config = new wificonfiguration(); n1config.ssid = "\"networkone\""; n1config.presharedkey = "\"...\""; n1config.status = wificonfiguration.status.enabled; wificonfiguration n2config = new wificonfiguration(); n2config.ssid = "\"networktwo\""; n2config.hiddenssid = true; n2config.wepkeys[0] = "..."; n2config.weptxkeyindex = 0; n2config.allowedkeymanagement.set(wificonfiguration.keymgmt.none); n2config.allowedprotocols.set(wificonfiguration.protocol.rsn); n2config.allowedprotocols.set(wificonfiguration.protocol.wpa); n2config.allowedauthalgorithms.set(wificonfiguration.authalgorithm.open); n2config.allowedauthalgorithms.set(wificonfiguration.authalgorithm.shared); n2config.allowedpairwiseciphers.set(wificonfiguration.pairwisecipher.ccmp); n2config.allowedpairwiseciphers.set(wificonfiguration.pairwisecipher.tkip); n2config.allowedgroupciphers.set(wificonfiguration.groupcipher.wep40); n2config.allowedgroupciphers.set(wificonfiguration.groupcipher.wep104); n2config.allowedgroupciphers.set(wificonfiguration.groupcipher.ccmp); n2config.allowedgroupciphers.set(wificonfiguration.groupcipher.tkip); n2config.status = wificonfiguration.status.enabled; wifimanager wifimanager = (wifimanager)getsystemservice(context.wifi_service); int n1id = wifimanager.addnetwork(n1config); wifimanager.enablenetwork(n1id, false); int n2id = wifimanager.addnetwork(n2config); wifimanager.enablenetwork(n2id, false); }
i believe need call wifi.saveconfiguration(); after have added both of configurations wifimanager.
Comments
Post a Comment