Can I change the group owner in a persistent group in Wi-Fi Direct?

You can now create a new persistent group via WifiP2pManager.createGroup(..). It will create a new group and make the calling device (A) group owner and can do what you described. The only problem is once you create a group and connect to another device, that other device (B) will remember that specific group. If you … Read more

Getting WiFi signal strength in Android

its an old post but this might help someone… WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int numberOfLevels = 5; WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels); Documentation: public static int calculateSignalLevel (int rssi, int numLevels)

Send request over WiFi (without connection) even if Mobile data is ON (with connection) on Android M

Stanislav’s answer is correct but incomplete because only works in Lollipop. I’ve wrote a complete solution for Lollipop and Marshmallow onwards for you to route all network requests through WiFi when connected to a specific network of your choice. Kotlin In your Activity, @RequiresApi(Build.VERSION_CODES.LOLLIPOP) class RoutingActivity : Activity() { private var mConnectivityManager: ConnectivityManager? = null … Read more

How to turn off Wifi via ADB?

Using “svc” through ADB (rooted required): Enable: adb shell su -c ‘svc wifi enable’ Disable: adb shell su -c ‘svc wifi disable’ Using Key Events through ADB: adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings adb shell input keyevent 20 & adb shell input keyevent 23 The first line launch “wifi.WifiSettings” activity which open the … Read more

How to get each device’s IP address in Wi-Fi Direct scenario?

I encountered the same problem. Since both devices know the group owner’s ip, it is already possible to send a message to the group owner. The first message you send can contain the ip address of the other device; from then on, bidirectional communication is possible. Here’s a possibility for retrieving your ip in java: … Read more

Get my wifi ip address Android

So something to consider is that Formatter.formatIpAddress(int) is being deprecated: This method was deprecated in API level 12. Use getHostAddress(), which supports both IPv4 and IPv6 addresses. This method does not support IPv6 addresses. So using formatIpAddress(int) is likely not a good long term solution, although it will work. Here is a potential solution if … Read more