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 void hiddenKeybroad(View v, Context context) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:Main.java
public static int getMaxVoice(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Service.AUDIO_SERVICE); // return audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); return audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM); }
From source file:Main.java
public static UUID getUUID(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String uniqueId = tm.getDeviceId(); UUID deviceUuid = new UUID(uniqueId.hashCode(), 64); return deviceUuid; }
From source file:Main.java
public static String getPhoneNumber(Context context) { TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return phoneMgr.getLine1Number(); }
From source file:Main.java
public static boolean isGpsEnabled(Context context) { LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); List<String> accessibleProviders = manager.getProviders(true); return accessibleProviders != null && accessibleProviders.size() > 0; }
From source file:Main.java
public static void showKeyBoard(Context context) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static String getPhoneNumber(Context ctx) { TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); String phoneNumber = tm.getLine1Number(); if (phoneNumber == null || phoneNumber.length() == 0) { return null; }//from w w w. j a v a 2 s . c o m phoneNumber = phoneNumber.replace("+82", "0"); return phoneNumber; }
From source file:Main.java
public static String getDeviceId(Context context) { TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return phoneMgr.getDeviceId(); }
From source file:Main.java
public static boolean isInternetAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isScreenLight(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); return pm.isScreenOn(); }