Example usage for android.content Context getSystemService

List of usage examples for android.content Context getSystemService

Introduction

In this page you can find the example usage for android.content Context getSystemService.

Prototype

@SuppressWarnings("unchecked")
public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) 

Source Link

Document

Return the handle to a system-level service by class.

Usage

From source file:Main.java

public static void cancel(Context context) {
    ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).cancel();
}

From source file:Main.java

public static boolean isNetworkAvailable(Context context) {
    return (context.getSystemService(Context.CONNECTIVITY_SERVICE) != null)
            && (((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE))
                    .getActiveNetworkInfo() != null);
}

From source file:Main.java

public static void vibrar(Context context) {
    ((Vibrator) context.getSystemService(context.VIBRATOR_SERVICE)).vibrate(200);
}

From source file:Main.java

public static void cancel(final Context context) {
    ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).cancel();
}

From source file:Main.java

public static AlarmManager getAlarmManager(Context ctx) {
    return (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
}

From source file:Main.java

public static WifiManager getWifiManager(Context ctx) {
    return (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
}

From source file:Main.java

private static AlarmManager alarmManager(Context con) {
    return (AlarmManager) con.getSystemService(Context.ALARM_SERVICE);
}

From source file:Main.java

public static boolean isScreenOn(Context context) {
    return ((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isScreenOn();
}

From source file:Main.java

public static boolean isWIFIActivate(Context context) {
    return ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).isWifiEnabled();
}

From source file:Main.java

public static int getScreenHeight(Context context) {
    return ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
}