List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
public static boolean isFlymeOs4x() { String sysVersion = android.os.Build.VERSION.RELEASE; if ("4.4.4".equals(sysVersion)) { String sysIncrement = android.os.Build.VERSION.INCREMENTAL; String displayId = android.os.Build.DISPLAY; if (!TextUtils.isEmpty(sysIncrement)) { return sysIncrement.contains("Flyme_OS_4"); } else {/* w ww . ja va2 s. c om*/ return displayId.contains("Flyme OS 4"); } } return false; }
From source file:Main.java
public static boolean isForeground(Context context, String className) { if (context == null || TextUtils.isEmpty(className)) { return false; }/* ww w . j a v a 2s . c o m*/ ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> list = am.getRunningTasks(1); if (list != null && list.size() > 0) { ComponentName cpn = list.get(0).topActivity; if (className.equals(cpn.getClassName())) { return true; } } return false; }
From source file:Main.java
public static Map<String, String> getOption(int skip, int limit, String sort) { Map<String, String> options = new ArrayMap<>(); options.put("skip", skip + ""); options.put("limit", limit + ""); if (!TextUtils.isEmpty(sort)) options.put("sort", sort); return options; }
From source file:Main.java
public static boolean hasLength(EditText editText) { // text never null! String str = editText.getText().toString(); if (!TextUtils.isEmpty(str)) { return str.trim().length() > 0; } else {/*from w w w . j av a 2s . c o m*/ return false; } }
From source file:Main.java
public static void ToastMsg(Context context, String msg) { if (context == null || TextUtils.isEmpty(msg)) { return;// w w w .j a v a 2 s .c o m } if (mToast != null) { mToast.cancel(); mToast = null; } mToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT); mToast.show(); }
From source file:Main.java
public static String getIMEI(Context context) { TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imei = mTelephonyMgr.getDeviceId(); if (TextUtils.isEmpty(imei) || imei.equals("000000000000000")) { imei = "0"; }/* w ww . j a v a 2 s.c om*/ return imei; }
From source file:Main.java
public static void toastMessageLong(Context context, String message) { if (context == null) { return;//from w w w . jav a2 s . c o m } if (TextUtils.isEmpty(message)) { sToast = null; return; } if (sToast != null) { sToast.cancel(); sToast = null; } sToast = getToast(context); sToast.setDuration(Toast.LENGTH_LONG); sToast.setText(message); sToast.show(); }
From source file:Main.java
public static boolean isServiceRunning(Context context, String className) { if (context == null) return false; if (TextUtils.isEmpty(className)) return false; boolean isRunning = false; ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> servicesList = activityManager .getRunningServices(Integer.MAX_VALUE); for (ActivityManager.RunningServiceInfo si : servicesList) { if (className.equals(si.service.getClassName())) { isRunning = true;/*from w w w. j a v a 2s . c om*/ } } return isRunning; }
From source file:Main.java
public static String getDeviceId() { String IMEI = telephonyManager.getDeviceId(); if (TextUtils.isEmpty(IMEI)) { IMEI = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID); }/*from ww w . ja va 2s .c om*/ return IMEI; }
From source file:Main.java
public static String getAuthorityFromPermission(Context context, String permission) { if (TextUtils.isEmpty(permission)) { return null; }//from w w w . j av a 2s . c o m List<PackageInfo> packs = context.getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS); if (packs == null) { return null; } for (PackageInfo pack : packs) { ProviderInfo[] providers = pack.providers; if (providers != null) { for (ProviderInfo provider : providers) { if (permission.equals(provider.readPermission) || permission.equals(provider.writePermission)) { return provider.authority; } } } } return null; }