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 mContext) { WindowManager manager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
public static void show(Context context) { InputMethodManager m = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
/** * @param context Context of application * @return MAC address/*from w ww. jav a 2 s . c o m*/ */ public static String getMacAddress(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); return wifiManager.getConnectionInfo().getMacAddress(); }
From source file:Main.java
public static int getWindowHeigh(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); int mScreenHeigh = dm.heightPixels; return mScreenHeigh; }
From source file:Main.java
public static void adjustVoiceToSystemSame(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_SAME, 0); }
From source file:Main.java
public static void showKeyboard(Context context, View view) { imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(view, 0);/* ww w .ja v a2s .c o m*/ // imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); }
From source file:Main.java
@TargetApi(11) public static void copy(String content, Context context) { ClipboardManager cmb = (ClipboardManager) context.getSystemService("clipboard"); cmb.setText(content.trim());/*from ww w. j a va 2 s . c o m*/ }
From source file:Main.java
public static boolean hasInternetConnection(Context c) { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }
From source file:Main.java
public static String getIMEI(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String deviceId = tm.getDeviceId(); tm = null;/*from www . j a va2s. c o m*/ return deviceId; }
From source file:Main.java
public static String getLocalMacAddress(Context context) { WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); if (info != null) { return info.getMacAddress(); }//ww w. ja va 2 s . c o m return null; }