List of usage examples for java.lang Integer MAX_VALUE
int MAX_VALUE
To view the source code for java.lang Integer MAX_VALUE.
Click Source Link
From source file:Main.java
public static boolean isServiceRunning(Context mContext, String className) { boolean isRunning = false; android.app.ActivityManager activityManager = (android.app.ActivityManager) mContext .getSystemService(Context.ACTIVITY_SERVICE); List<android.app.ActivityManager.RunningServiceInfo> serviceList = activityManager .getRunningServices(Integer.MAX_VALUE); if (serviceList.size() == 0) { return false; }/*from w w w . java 2s . com*/ for (int i = 0; i < serviceList.size(); i++) { if (serviceList.get(i).service.getClassName().equals(className) == true) { isRunning = true; break; } } return isRunning; }
From source file:Main.java
/** * Check if service is running or not//from w ww . j a v a 2s . c om * * @param serviceName * @param context * @return */ public static boolean isServiceRunning(String serviceName, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceName.equals(service.service.getClassName())) { return true; } } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> serviceList = activityManager .getRunningServices(Integer.MAX_VALUE); if (serviceList == null || serviceList.isEmpty()) return false; for (int i = 0; i < serviceList.size(); i++) { if (serviceList.get(i).service.getClassName().equals(className) && TextUtils.equals(serviceList.get(i).service.getPackageName(), context.getPackageName())) { isRunning = true;/* w ww. ja v a 2 s . c o m*/ break; } } return isRunning; }
From source file:Main.java
public static boolean isServiceRunning(Context ctx, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE); Iterator<RunningServiceInfo> l = servicesList.iterator(); while (l.hasNext()) { RunningServiceInfo si = (RunningServiceInfo) l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;/* w w w .j a v a 2s . com*/ } } return isRunning; }
From source file:Main.java
public static int[] findClosestFpsRange(Camera camera, int minFrameRate, int maxFrameRate) { minFrameRate *= 1000;//from www .ja v a 2s .c o m maxFrameRate *= 1000; Camera.Parameters parameters = camera.getParameters(); int minIndex = 0; int minDiff = Integer.MAX_VALUE; List<int[]> rangeList = parameters.getSupportedPreviewFpsRange(); Log.d(TAG, "support preview fps range list: " + dumpFpsRangeList(rangeList)); for (int i = 0; i < rangeList.size(); i++) { int[] fpsRange = rangeList.get(i); if (fpsRange.length != 2) { continue; } int minFps = fpsRange[0] / 1000; int maxFps = fpsRange[1] / 1000; int diff = Math.abs(minFps - minFrameRate) + Math.abs(maxFps - maxFrameRate); if (diff < minDiff) { minDiff = diff; minIndex = i; } } int[] result = rangeList.get(minIndex); return result; }
From source file:Main.java
public static boolean isServiceRunning(Context ctx, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> servicesList = activityManager .getRunningServices(Integer.MAX_VALUE); Iterator<ActivityManager.RunningServiceInfo> l = servicesList.iterator(); while (l.hasNext()) { ActivityManager.RunningServiceInfo si = (ActivityManager.RunningServiceInfo) l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;/*from w w w.j av a 2 s . c om*/ } } return isRunning; }
From source file:Main.java
public static boolean isWorked(Context context, String serviceName) { ActivityManager myManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ArrayList<RunningServiceInfo> runningService = (ArrayList<RunningServiceInfo>) myManager .getRunningServices(Integer.MAX_VALUE); for (RunningServiceInfo runningServiceInfo : runningService) { if (runningServiceInfo.service.getClassName().equals(serviceName)) { return true; }/* w ww . j a va 2s . c o m*/ } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String className) { boolean isServiceFound = false; try {/* w w w . j a v a 2 s . c o m*/ ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE); for (int i = 0; i < services.size(); i++) { if (services.get(i).topActivity.getClassName().equalsIgnoreCase(className)) { isServiceFound = true; } } } catch (Exception ex) { } return isServiceFound; }
From source file:Main.java
public static byte[] readBytes(File file) throws IOException { //check/*from w ww .j av a 2 s. com*/ if (!file.exists()) { throw new FileNotFoundException("File not exist: " + file); } if (!file.isFile()) { throw new IOException("Not a file:" + file); } long len = file.length(); if (len >= Integer.MAX_VALUE) { throw new IOException("File is larger then max array size"); } byte[] bytes = new byte[(int) len]; FileInputStream in = null; try { in = new FileInputStream(file); in.read(bytes); } finally { close(in); } return bytes; }
From source file:Main.java
public static Bitmap drawableToBitmap(Drawable drawable) { Bitmap bitmap = null;/* www .j a v a 2 s .c o m*/ if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; bitmapDrawable.setAntiAlias(true); bitmapDrawable.setDither(true); bitmapDrawable.setTargetDensity(Integer.MAX_VALUE); if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }