You are checking if netinfo
is null only after using it, and you probably get a NullPointerException:
Log.v("Test--",""+netInfo.isAvailable()); // << here
if ( netInfo != null && netInfo.isConnectedOrConnecting()&& netInfo.isAvailable()) {
return true;
}