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

private static ClipboardManager getManager(Context context) {
    return (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
}

From source file:Main.java

public static WindowManager getWindowManager(Context context) {
    return (WindowManager) context.getSystemService(Activity.WINDOW_SERVICE);
}

From source file:Main.java

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

From source file:Main.java

public static Display getDefaultDisplay(Context context) {
    return ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
}

From source file:Main.java

/** get BluetoothManager */
public static BluetoothManager getManager(Context context) {
    return (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
}

From source file:Main.java

public static String getIntservicemer(Context context) {
    return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkOperatorName();
}

From source file:Main.java

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

From source file:Main.java

public static void toggleSoftKeyboardState(Context context) {
    ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE))
            .toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static int getRingVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamVolume(AudioManager.STREAM_RING);
}

From source file:Main.java

public static InputMethodManager from(Context context) {
    return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
}