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 String getIMEI(Context ctx) {
    TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = tm.getDeviceId();
    return imei;//from w w w. ja  va 2  s .  c o  m
}

From source file:Main.java

public static Point getScreenSize(Context ctx) {
    WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    display.getSize(sPoint);/*from  w ww.  j  ava  2 s. co  m*/
    return sPoint;
}

From source file:Main.java

public static String getDeviceId(Context ctx) {
    TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);

    return tm.getDeviceId();
}

From source file:Main.java

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

From source file:Main.java

public static int getScreenHeight(Context context) {

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return wm.getDefaultDisplay().getHeight();

}

From source file:Main.java

public static String getIp(Context ctx) {
    WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wi = wm.getConnectionInfo();
    int ip = wi.getIpAddress();
    String ipAddress = intToIp(ip);
    return ipAddress;
}

From source file:Main.java

public static String getDevId(Context context) {
    return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
}

From source file:Main.java

public static int getWindowWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics metric = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(metric);
    return metric.widthPixels;
}

From source file:Main.java

public static boolean haveLockScreen(Context context) {
    KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    return km.inKeyguardRestrictedInputMode();
}

From source file:Main.java

public static int getScreenWidth(Context context) {

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    return wm.getDefaultDisplay().getWidth();

}