List of usage examples for android.content Context getSystemService
@SuppressWarnings("unchecked") public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass)
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); int height = wm.getDefaultDisplay().getHeight(); return Math.min(width, height); }
From source file:Main.java
public static float getScreenWidthPPI(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); return outMetrics.xdpi; }
From source file:Main.java
public static String paste(Context context) { ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); return cmb.getText().toString().trim(); }
From source file:Main.java
public static boolean isSleeping(Context context) { KeyguardManager kgMgr = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); return kgMgr.inKeyguardRestrictedInputMode(); }
From source file:Main.java
public static boolean isRingerEnable(Context context) { AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); final int audioMode = am.getRingerMode(); if (audioMode == AudioManager.RINGER_MODE_NORMAL) { return true; } else {/* ww w .j a v a2s.com*/ return false; } }
From source file:Main.java
public static String getPhoneNumber(Context context) { TelephonyManager tMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tMgr.getLine1Number(); }
From source file:Main.java
public static int getWindowHeight(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); return display.getHeight(); }
From source file:Main.java
public static void hideSoftKeyBroad(Context context, EditText edittext) { ((InputMethodManager) context.getSystemService("input_method")) .hideSoftInputFromWindow(edittext.getWindowToken(), 0); }
From source file:Main.java
public static String getIMEI(Context mContext) { TelephonyManager tel = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); return tel.getDeviceId(); }
From source file:Main.java
private static WifiInfo getWifiInfo(Context context) { WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); return mWifiManager.getConnectionInfo(); }