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 AlarmManager getAlarmManager(Context context) {
    return (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
}

From source file:Main.java

public static WifiManager getWifiManager(Context pContext) {
    return (WifiManager) pContext.getSystemService("wifi");
}

From source file:Main.java

private static AppOpsManager getAppOpsManager(Context context) {
    return (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
}

From source file:Main.java

private static AlarmManager am(Context context) {
    return (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
}

From source file:Main.java

public static int getDisplayWidth(Context context) {
    return ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getWidth();
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    return ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getWidth();
}

From source file:Main.java

private static int getMemoryClass(Context context) {
    return ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
}

From source file:Main.java

public static void cancelAllNotification(Context context) {
    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).cancelAll();
}

From source file:Main.java

public static TelephonyManager getTelephonyManager(Context context) {
    return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}

From source file:Main.java

public static int getDisplayHeight(Context context) {
    return ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getHeight();
}