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 getOperationName(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getNetworkOperatorName() == null ? "" : tm.getNetworkOperatorName();
}

From source file:Main.java

public static String getFromClipboard(Context context) {
    ClipboardManager c = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
    return c.getText().toString();
}

From source file:Main.java

public static boolean isGPSEnabled(Context context) {
    LocationManager lm = ((LocationManager) context.getSystemService(Context.LOCATION_SERVICE));
    List<String> accessibleProviders = lm.getProviders(true);
    return accessibleProviders != null && accessibleProviders.size() > 0;
}

From source file:Main.java

public static DisplayMetrics getScreenInfo(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    return dm;/*ww  w. j a  va2  s .c om*/
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getDeviceID(Context context) {
    String id = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
    if (TextUtils.isEmpty(id)) {
        id = "000000000000000";
    }/*from www .  j  a  va  2s. c  o  m*/
    return id;
}

From source file:Main.java

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

From source file:Main.java

public static String getNetworkCountryIso(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getNetworkCountryIso();
}

From source file:Main.java

public static boolean checkClipborad(Context context) {
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    return cmb.hasText();
}