List of utility methods to do Context Check
boolean | isLocationEnabledGPS(Context c) is Location Enabled GPS LocationManager lm = (LocationManager) c
.getSystemService(Context.LOCATION_SERVICE);
return lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
boolean | isMobile(Context context) is Mobile ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager .getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) { return true; return false; |
boolean | isMobilityInstalled(Context context) Returns true if mobility and accelservice are installed return getMobilityPackageInfo(context) != null;
|
Boolean | isNetAvailable(Context context) is Net Available try { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobileInfo = connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifiInfo.isConnected() || mobileInfo.isConnected()) { ... |
boolean | isOnline(Context c) is Online try { ConnectivityManager cm = (ConnectivityManager) c .getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo().isConnectedOrConnecting(); } catch (Exception e) { return false; |
boolean | isOnline(Context context) is Online ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { return true; return false; |
boolean | isOnline(Context context) is Online ConnectivityManager con_manager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
return con_manager.getActiveNetworkInfo() != null
&& con_manager.getActiveNetworkInfo().isAvailable()
&& con_manager.getActiveNetworkInfo().isConnected();
|
boolean | isOnline(Context context) Check if internet connection is up ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnectedOrConnecting();
|
boolean | isOnline(Context context) is Online ConnectivityManager connMgr = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
|
boolean | isPermissionGranted(Context ctx) Check BATTERY_STATS permission. PackageManager pm = ctx.getPackageManager(); int perm = pm.checkPermission( android.Manifest.permission.BATTERY_STATS, ctx.getPackageName()); return (perm == PackageManager.PERMISSION_GRANTED); |