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 getSreenHeight(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return wm.getDefaultDisplay().getHeight();
}

From source file:Main.java

public static void enableBluetoothRouting(Context context) {
    AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    am.startBluetoothSco();/*  w ww .j  a v  a2 s .  com*/
    am.setBluetoothScoOn(true);
}

From source file:Main.java

public static final String getLocalMacAddress(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    return info.getMacAddress();
}

From source file:Main.java

public static int[] getScreenParams(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return new int[] { wm.getDefaultDisplay().getWidth(), wm.getDefaultDisplay().getHeight() };
}

From source file:Main.java

public static int getWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return wm.getDefaultDisplay().getWidth();
}

From source file:Main.java

public static void cancelNotification(Context context, int notifyId) {
    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(notifyId);
}

From source file:Main.java

public static String getIMEI(Context ctx) {
    return ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
}

From source file:Main.java

public static boolean isNetworkConnected(Context paramContext) {
    return ((ConnectivityManager) paramContext.getSystemService(Context.CONNECTIVITY_SERVICE))
            .getActiveNetworkInfo() != null;
}

From source file:Main.java

public static int getWidthScreen(Context context) {
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    return display.getWidth();
}

From source file:Main.java

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