31May/110
Checking for Internet connection on Android
Here is simple example for internet connection check on Android devices:
private boolean checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != null
&& cm.getActiveNetworkInfo().isAvailable()
&& cm.getActiveNetworkInfo().isConnected()) {
return true;
} else {
return false;
}
}
31May/110
Getting Manufacturer on Android Device
It was hard to investigate the problem with version 1.5 and Build Manufacturer, and here is the solution:
public String GetManufacturer(){
try {
return android.os.Build.class.getField("MANUFACTURER").get(null).toString();
} catch (Exception e) {
return "undefined";
}
}
Now we will catch Exception without Unexpected Error in Runtime.