i would like to ask:
I have in my AppHelper class following method which check availability of internet connection.
public boolean checkInternetConnection(Context ctx) {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != null
&& cm.getActiveNetworkInfo().isAvailable()
&& cm.getActiveNetworkInfo().isConnected()) {
return true;
} else {
Log.i(GlobalApplication.APP_LOG_NAMESPACE, "Internet Connection Not Present");
return false;
}
}
Im trying to get Boolean value by using:
// check internet connection and availability
Boolean isConnectionAvailable = appHelper.checkInternetConnection(getBaseContext());
But unfortunately i get always null pointer exception. Is it matter of passed application context? And how should i solve that issue?
Thanks for any advice.