android-wifi

Enabling WiFi on Android Emulator

坚强是说给别人听的谎言 提交于 2019-11-26 10:33:07
问题 How to enable WiFi on Android emulator? I have tried to find this but everyone is confusing WiFi with 3G. 回答1: Wifi is not available on the emulator if you are using below of API level 25. When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it. More Information: https://developer.android.com/studio/run/emulator.html#wifi 回答2: Apparently it does not and I didn't quite expect it would. HOWEVER

How to get each device'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

Getting WiFi signal strength in Android

喜你入骨 提交于 2019-11-26 10:27:54
问题 I can get WiFi signal level in dBm using following code. for (ScanResult result : wifiScanResultList) { int signalLevel = result.level; } It gives negative value. When we see the default system WiFi setting and clicked on the connected WiFi network, it gives \"Good\" or \"Bad\" as signal strength. What is the range that we can filter those negative vales as \"Good\" signal strength or \"Bad\" signal strength? 回答1: its an old post but this might help someone... WifiManager wifiManager =

How to turn off Wifi via ADB?

不羁的心 提交于 2019-11-26 10:16:53
问题 Im automating a testing procedure for wifi calling and I was wondering is there a way to turn off/on wifi via adb? I would either like to disable/enable wifi or kill wifi calling (com.movial.wificall) and restart it. Is it possible to do this all via adb and shell commands? so far I have found: android.net.wifi.WifiManager setWifiEnabled(true/false) Im just not sure how to put it together 回答1: Using "svc" through ADB (rooted required): Enable: adb shell su -c 'svc wifi enable' Disable: adb

CONNECTIVITY_ACTION intent received twice when Wifi connected

依然范特西╮ 提交于 2019-11-26 10:10:09
问题 In my app I have a BroadcastReceiver that is launched as a component through a <receiver> tag, filtering android.net.conn.CONNECTIVITY_CHANGE intents. My goal is simply to know when a Wifi connection was established, so what I am doing in onReceive() is this: NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if(networkInfo.getType() == ConnectivityManager.TYPE_WIFI && networkInfo.isConnected()) { // Wifi is connected } It works fine, but I always

How to avoid delay in Android GCM messages / change heartbeat

房东的猫 提交于 2019-11-26 08:49:52
问题 I\'ve been reading many posts regarding a GCM issue that affects some people. It seems that in some devices/routers/carriers the notifications suffer delays. I\'ve experienced this issue with my router: messages came with a lot of delay on WIFI but came instantly when I disabled WIFI and connected to the mobile net. It seems there is a workaround that can be done from the Android app. Something like increasing the heartbeat that keeps GCM connection alive, or so. Can anyone tell us what

Android 2.3 wifi hotspot API

痴心易碎 提交于 2019-11-26 08:01:44
问题 What is the API call I need to make in Android 2.2 (Froyo) to create a Wifi hotspot (as seen in the Tethering and Portable Hotspot settings item). 回答1: There is no official API, but you can use reflection to handle it. I know some say, it's not recommended, however imho I say, screw it if Google doesn't want to provide an API for whatever reason. Below is the code of an activity I used in my application, where the user can enable/disable the Wifi AP. When you enable Wifi AP, usually the

How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo)

大憨熊 提交于 2019-11-26 07:42:20
问题 I know how to turn on/off wifi hot spot using reflection in android using below method. private static boolean changeWifiHotspotState(Context context,boolean enable) { try { WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); Method method = manager.getClass().getDeclaredMethod(\"setWifiApEnabled\", WifiConfiguration.class, Boolean.TYPE); method.setAccessible(true); WifiConfiguration configuration = enable ? getWifiApConfiguration(manager) : null; boolean

How can I get Android Wifi Scan Results into a list?

落花浮王杯 提交于 2019-11-26 06:42:19
I know how to get a <List> of Android Wifi Scans but I can not figure out the best way to make a list adapter out of them. I would like to just bind SSID and BSSID from a <List> of scans to text1 and text2. Samples of what I have been doing wifi.startScan(); // get list of the results in object format ( like an array ) List<ScanResult> results = wifi.getScanResults();` // loop that goes through list for (ScanResult result : results) { Toast.makeText(this, result.SSID + " " + result.level, Toast.LENGTH_SHORT).show(); And: private void fillDataFromDb() { Cursor scanCursor = Db.fetchAllScans();

Get my wifi ip address Android

白昼怎懂夜的黑 提交于 2019-11-26 06:30:25
问题 How can I get the ip address of my phone when it is connected under wifi? I found a method here but it returns something like 24.182.239.255 even if I\'m under wifi and I expect something like 192.168.1.10. I\'d like something like: if (you are under wifi) String ip4 = getWifiIP() else String ip4 = getIPAddress with the method linked before Many thanks! 回答1: If you would like to get the private IP address of your device when connected to Wi-Fi, you can try this. WifiManager wifiMgr =