The call "WifiInfo wifiInfo = wifiManager.getConnectionInfo()" causes the "unfortunately, xxx has stopped" error, resulting in my emulator crashing. I can't seem to get around what the issue with this is; I don't think I need to throw a try-catch block...?
Where's the logcat for this? Possibly: does your app have ACCESS_NETWORK_STATE
permission?
A similar "unfortunately, xxx has stopped" error occurs when I input a website in urlString. When I leave the field blank, the bandwidth becomes -1, as no website gets specified, and an Exception gets thrown.
Don't do network operations on the UI thread. Easy solution is to use an AsyncTask
to do them on a background thread. For more info: How to fix android.os.NetworkOnMainThreadException?