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 double getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return 0.0;//from w w w .ja v a 2s . c o m }
From source file:Main.java
@SuppressWarnings("deprecation") public static CharSequence getClipboard(Context context) { return ((android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).getText(); }
From source file:Main.java
public static String getMacAddress(Context context) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wm.getConnectionInfo(); return info.getMacAddress(); }
From source file:Main.java
public static int getMemoryClass(Context context) { return ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); }
From source file:Main.java
public static String getPhoneIMEI(Context cxt) { TelephonyManager tm = (TelephonyManager) cxt.getSystemService(Context.TELEPHONY_SERVICE); return tm.getDeviceId(); }
From source file:Main.java
public static void setVolume(int volume, Context context) { AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); manager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0); }
From source file:Main.java
public static int getVolume(Context context) { AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); return manager.getStreamVolume(AudioManager.STREAM_MUSIC); }
From source file:Main.java
/** * Gets the device id.//from ww w . ja v a 2s.co m * * @param context the context * @return the device id */ public synchronized static String getDeviceId(Context context) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); return wm.getConnectionInfo().getMacAddress(); }
From source file:Main.java
public static int screenWitdh(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); return width; }
From source file:Main.java
public static void hideKeyboard(Context ctx, EditText editText) { ((InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }