wifimanager

Android - Get Notified when a new access point is detected?

一个人想着一个人 提交于 2019-12-22 10:51:39
问题 Does Android provide a notification of being in vicinity of a new Wifi Network? Whether the device is configured to connect to that wifi network depends on whether the device has the wifi configuration set for that particular wifi network, but is it possible to get notification whenever entering any new wifi network? I saw the WifiManager class but the states inside the class do not seem to achieve what I am trying to do. Any ideas? 回答1: Use a BroadcastReceiver registered to receive intents

Is it possible to add a network configuration on Android Q?

女生的网名这么多〃 提交于 2019-12-22 05:52:07
问题 Background I've noticed that in WifiManager class there is a function called addNetwork, that might be useful if I want to restore or save networks information (network name AKA SSID, together with the password and the type), so that I could also connect to it. The problem I can't find much information about how to do such a thing. I've seen various examples on StackOverflow, and if I target Android API 28 (or below), I indeed succeed to make it add a network and even connect to it. When

How do I connect to a WiFi Network with an unknown encryption algorithm in Android?

走远了吗. 提交于 2019-12-21 23:01:23
问题 I have researched this question on StackOverflow , but all answers specify how to connect to a network with a known encryption algorithm (mostly WEP). In my application, I retrieve a list of available wifi networks, and display them in a ListView (using WifiManager ). When the user clicks one of the items in the list, I want to connect to the network. My current implementation attempts to get the WifiConfiguration data from a ScanResult 's capabilities String. For example, these are all

How to get the MAC address of an android device(WIFI is switched off) through code?

不想你离开。 提交于 2019-12-21 06:06:15
问题 I need to design an Android app that should display the MAC address of the device.. I have already done the following coding.. WifiManager wifimanager = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo winfo = wifimanager.getConnectionInfo(); String MACAddress = winfo.getMACAdress(); But the problem is, this code is working only when wifi is turned on, but my requirement is to find the MAC address whether wifi is turned on or not. 回答1: Here is the code to getMac Address without

Extracting SSID password from supplicant config file in Android

社会主义新天地 提交于 2019-12-21 05:32:25
问题 I'm trying to write an Android SYSTEM app that extracts the Wifi password from the supplicant configuration file (/data/misc/wifi/wpa_supplicant.conf). Using adb with root permissions, I can read the file without any problem and see the password in plain text. However, when I try to open the file programatically I get EACCES (Permission denied) error. That happens even though my app is running as 'system' user (I define android:sharedUserId="android.uid.system" in the manifest), the app is

startscan() has result after 10 min when phone get into idle state

纵然是瞬间 提交于 2019-12-20 04:35:17
问题 I am trying to scan wifi networks every 2 minutes. I am using service for that. When the phone is "active" or "in use" after startscan() called I get SCAN_RESULTS_AVAILABLE_ACTION in 6 sec. So i can scan for wifis periodically. But after the phone has not been touched by anyone for a certain time (10 min) startscan() stops "working" and only after 10 min getting result. Anybody experienced this? 回答1: According to this I have found the solution - this is because the Wifi sleep policy. You can

Can't set “WifiConfiguration” when enabling wifi-hotspot using “setWifiApEnabled”

只愿长相守 提交于 2019-12-20 02:59:08
问题 I'm trying to set my Android device to be an Access-Point using the code I've seen here before: WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiConfiguration netConfig = new WifiConfiguration(); netConfig.SSID = "MyAccessPoint"; Method method = wifi.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class); method.invoke(wifi, netConfig, true); now, I managed to turning it on but without the SSID which I set in WifiConfiguration. This is

Issue with WifiManager.calculateSignalLevel(RSSI, 5)

扶醉桌前 提交于 2019-12-18 12:44:07
问题 I am trying to use the Wifimanager to calculate the Signal Level of the access points found during a scan. I am using the following method: WifiManager.calculateSignalLevel(int, int) But it appears to always return the same int no matter what the RSSI level is. Here is my code: public int calculateQoS(int aRSSI){ signalLevel = WifiManager.calculateSignalLevel(RSSI, 5); return signalLevel; } public void testCalculateQoS(){ Log.d("signal", "signal = : " + connMonitor.calculateQoS(-44) + " " +

android.net.wifi.STATE_CHANGE: not triggered on Wifi disconnect

半腔热情 提交于 2019-12-18 10:19:38
问题 Is it normal to only have a broadcast intent with action NETWORK_STATE_CHANGED_ACTION (whose constant value is android.net.wifi.STATE_CHANGE ) when a Wifi connection is coming back up? I.e. I don't get this intent when Wifi is being disconnected. UPDATE: I am mostly interested to >= 2.2 Froyo 回答1: public static final String SUPPLICANT_CONNECTION_CHANGE_ACTION Since: API Level 1 Broadcast intent action indicating that a connection to the supplicant has been established (and it is now possible

Android WifiManager.addNetwork() returns -1

不问归期 提交于 2019-12-17 19:32:41
问题 I am writing an android app which will connect to a specific WPA access point, when connected, it will issue a http call. It will not save the network config. I have read almost every post on stack overflow on connecting to wifi network but can't find the answer which works for me. Here is the code I am using to connect.. WifiConfiguration wc = new WifiConfiguration(); wc.allowedAuthAlgorithms.clear(); wc.allowedGroupCiphers.clear(); wc.allowedPairwiseCiphers.clear(); wc.allowedProtocols