Android: Simulate WiFi in the emulator?

Currently, while you can use your computer’s Internet connection in the emulator, it’s not reliable to use it for simulating Wi-Fi. The WifiManager gets confused when you switch/want to test your connectivity state. Even in Android 1.5, there were some problems with it (Issue 2571 – android), and while you can use your Internet for … Read more

Java getting my IP address

String ip; try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface iface = interfaces.nextElement(); // filters out 127.0.0.1 and inactive interfaces if (iface.isLoopback() || !iface.isUp()) continue; Enumeration<InetAddress> addresses = iface.getInetAddresses(); while(addresses.hasMoreElements()) { InetAddress addr = addresses.nextElement(); ip = addr.getHostAddress(); System.out.println(iface.getDisplayName() + ” ” + ip); } } } catch (SocketException e) { throw new … Read more

Force Android to Use Wifi network with no internet

You can solve this by setting captive_portal_detection_enabled to 0 (false). What’s actually happening is that by default, everytime you connect to a wifi, the FW will test against a server (typically google) to see if it’s a captive wifi (needs login). So if your wifi is not connected to google, this check will fail. After … Read more

Getting MAC address in Android 6.0

Please refer to Android 6.0 Changes. To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00. To access the hardware identifiers of nearby … Read more

iOS Detect 3G or WiFi

Using the code that Apple has provided here Reachability *reachability = [Reachability reachabilityForInternetConnection]; [reachability startNotifier]; NetworkStatus status = [reachability currentReachabilityStatus]; if(status == NotReachable) { //No internet } else if (status == ReachableViaWiFi) { //WiFi } else if (status == ReachableViaWWAN) { //3G }

java.net.ConnectException: failed to connect to /192.168.253.3 (port 2468): connect failed: ECONNREFUSED (Connection refused)

A connect failed: ECONNREFUSED (Connection refused) most likely means that there is nothing listening on that port AND that IP address. Possible explanations include: the service has crashed or hasn’t been (successfully!) started, your client is trying to connect using the wrong IP address or port, your client is trying to connect using a DNS … Read more

ADB, Wifi and Eclipse: how I can configure?

First, run ‘adb connect ip:port’, like adb connect <phone-ip-address>, from console/terminal (with your IP address and port of cause). This makes adb service to connect to your device via network. Port 5555 is used by default if no port number is specified. Then check that device is correctly connected: run adb devices from console/terminal (make … Read more

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