List of usage examples for android.content ContextWrapper getSystemService
@Override
public Object getSystemService(String name)
From source file:Main.java
/** * Get the notification manager service. * //from w w w.ja v a2 s . c o m * @param context * @return {@link NotificationManager} */ public static NotificationManager getManager(final ContextWrapper context) { return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); }
From source file:Main.java
/** * Determines if the device's wifi is currently enabled or not. * //from www . j a va 2 s. co m * @param context A context with which to access wifi system service * @return True if wifi is enabled or enabling, false otherwise */ public static boolean wifiIsEnabled(ContextWrapper context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int wifiState = wifiManager.getWifiState(); return (wifiState == WifiManager.WIFI_STATE_ENABLED || wifiState == WifiManager.WIFI_STATE_ENABLING); }
From source file:Main.java
/** * Determines if the network is currently available or not. * /*w w w. j a va 2 s. com*/ * @param context The context with which to access the system connectivity service * @return True if the network is available, false if not */ public static boolean isNetworkAvailable(ContextWrapper context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo network = cm.getActiveNetworkInfo(); return ((network != null) && (network.isConnected())); }
From source file:Main.java
/** * Enables or disables wifi. Requires CHANGE_WIFI_STATE permission. * /* w w w .j a va 2 s . co m*/ * @param context A context with which to access wifi system service * @param enable True if wifi should be enabled, false if it should be disabled */ public static void enableWifi(ContextWrapper context, boolean enable) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(enable); }