I\'m having a weird error on my android application. I\'m testing with a local server using Xampp. The App is to retrieve records from a Database and store them in the phone.
You can also add a check for internet connection before making any request so that user will get to know internet is not there.
Use below code and if it return false show Toast/Alert.
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
Have a case when my app is connecting then turn off wifi > app crash and it cannot go inside catch command Exception.
please check Internet/WiFi connection on the device
I've figured out what was the problem! The Samsung Fame wasn't connected to the Wi-Fi. It had no internet.