wifimanager

Android : Reconnect to Wi-Fi after entering coverage area while screen turned off

旧街凉风 提交于 2019-11-26 20:47:02
问题 I have been struggling with automatically turning on Wi-Fi as soon as the device is within range of an access point without turning on the screen. It has been very frustrating to test and figure out a solution, especially since different devices have completely different results. Base Test Keep the screen turned off during this test. The application should hold a WifiLock. Walk out of WiFi coverage and stay there for a minute. Walk back into coverage. Result : The Wifi is not reconnected

How to be notified when a peer is no longer available in the Wi-Fi Direct range?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 20:17:23
问题 I am developing an Android application based on the use of Wifi Direct API. I have registered in my Activity a BroadcastReceiver in order to be notified about the following Wifi Direct events: WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION I believed that any change in the list of peers (the inclusion or exclusion of a peer in the Wifi Direct range)

Android get IP-Address of a hotspot providing device

浪尽此生 提交于 2019-11-26 19:56:14
问题 I'm currently using public static String getLocalIPAddress(WifiManager wm){ return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); } to get the IP-Address of the executing devices. That works fine if the device is connected to a "common" wlan-network as well as the device is connected to a wifi network which is hosted by an other android device via hotspot. If the device is not connected to any wifi network "0.0.0.0" is returned (correct). But if the device is hosting a wifi

Turning on wifi using WifiManager stops to work on Android 10

混江龙づ霸主 提交于 2019-11-26 18:35:50
问题 I have following code which used to work well pre Android 10. But it is not able to turn wifi on in Android 10 devices. WifiManager wifiMgr = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); boolean res = wifiMgr.setWifiEnabled(true); //res value is set to false above because setWifiEnabled returns false on Android 10 Following are my permissions in AndroidManifest.xml <uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/> <uses-permission

How to get each device&#39;s IP address in Wi-Fi Direct scenario?

邮差的信 提交于 2019-11-26 10:29:38
问题 Starting from ICS, Wi-Fi Direct is introduced. Normally, we use the WifiP2pManager class to operate on Wi-Fi Direct, but it seems that it can only retrieve the GroupOwner IP address after connected. But, actually, any device all came negotiate to become the GroupOwner. In Upper Application, we need to get the peer\'s IP address, or each peer\'s IP address in a group so that we can send/communicate with them. How to get each IP address in Wi-Fi Direct? Include own IP address and each peer in

How to get available wifi networks and display them in a list in android

我与影子孤独终老i 提交于 2019-11-26 05:33:25
问题 Friends, I want to find all available WiFi networks and display them in a list I have tried as below. But it\'s not working. I have edited my code, and now I got the result but with all the result that I don\'t need. I only need names of wifi network in my list. public class MainActivity extends Activity { TextView mainText; WifiManager mainWifi; WifiReceiver receiverWifi; List<ScanResult> wifiList; StringBuilder sb = new StringBuilder(); @Override protected void onCreate(Bundle

How do I see if Wi-Fi is connected on Android?

ぐ巨炮叔叔 提交于 2019-11-26 01:22:03
问题 I don\'t want my user to even try downloading something unless they have Wi-Fi connected. However, I can only seem to be able to tell if Wi-Fi is enabled, but they could still have a 3G connection. android.net.wifi.WifiManager m = (WifiManager) getSystemService(WIFI_SERVICE); android.net.wifi.SupplicantState s = m.getConnectionInfo().getSupplicantState(); NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(s); if (state != NetworkInfo.DetailedState.CONNECTED) { return false; }

How do I connect to a specific Wi-Fi network in Android programmatically?

风格不统一 提交于 2019-11-25 21:48:33
问题 I want to design an app which shows a list of Wi-Fi networks available and connect to whichever network is selected by the user. I have implemented the part showing the scan results. Now I want to connect to a particular network selected by the user from the list of scan results. How do I do this? 回答1: You need to create WifiConfiguration instance like this: String networkSSID = "test"; String networkPass = "pass"; WifiConfiguration conf = new WifiConfiguration(); conf.SSID = "\"" +