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

CONNECTIVITY_ACTION intent received twice when Wifi connected

NOTE: For a recent, up-to-date answer, see this one below! After a lot of googling and debugging, I believe this is the correct way to determine if Wifi has connected or disconnected. The onReceive() method in the BroadcastReceiver: public void onReceive(final Context context, final Intent intent) { if(intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); if(networkInfo.isConnected()) { … 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)

Wifi Connect-Disconnect Listener

Actually you’re checking for whether Wi-Fi is enabled, that doesn’t necessarily mean that it’s connected. It just means that Wi-Fi mode on the phone is enabled and able to connect to Wi-Fi networks. This is how I’m listening for actual Wi-Fi connections in my Broadcast Receiver: public class WifiReceiver extends BroadcastReceiver { @Override public void … 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

Android turn On/Off WiFi HotSpot programmatically

Warning This method will not work beyond 5.0, it was a quite dated entry. Use the class below to change/check the Wifi hotspot setting: import android.content.*; import android.net.wifi.*; import java.lang.reflect.*; public class ApManager { //check whether wifi hotspot on or off public static boolean isApOn(Context context) { WifiManager wifimanager = (WifiManager) context.getSystemService(context.WIFI_SERVICE); try { Method … Read more

How to programmatically create and read WEP/EAP WiFi configurations in Android?

Part 1: Creating a WEP WiFi configuration programmatically This is pretty much straightforward, WifiConfiguration exposes the interface to create the same. Here is the sample code: void saveWepConfig() { WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiConfiguration wc = new WifiConfiguration(); wc.SSID = “\”SSID_NAME\””; //IMP! This should be in Quotes!! wc.hiddenSSID = true; wc.status = WifiConfiguration.Status.DISABLED; wc.priority … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)