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 int getActivityIconSize(Context c) {
    return 2 * ((ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE)).getLauncherLargeIconSize();
}

From source file:Main.java

public static AccountManager getManager(Context context) {
    return (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
}

From source file:Main.java

public static ConnectivityManager getConnectivityManager(Context ctx) {
    return (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
}

From source file:Main.java

public static int getMaxVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}

From source file:Main.java

public static BluetoothManager getBluetoothManager(Context context) {
    return (BluetoothManager) context.getSystemService("bluetooth");
}

From source file:Main.java

public static ActivityManager getActivityManager(Context context) {
    return (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
}

From source file:Main.java

public static Object getSystemService(Context context, String serviceName) {
    return context.getSystemService(serviceName);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static void showSoftInput(Context context) {
    ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE))
            .toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}