List of usage examples for android.util Log d
public static int d(String tag, String msg)
From source file:Main.java
public static int[] findClosestFpsRange(Camera camera, int minFrameRate, int maxFrameRate) { minFrameRate *= 1000;/*w ww .j a v a 2 s. 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
/** * Rename existing file in same directory if target file exists, delete * Code nicked from http://stackoverflow.com/users/325442/mr-bungle * @param context/*from ww w . j ava2 s . co m*/ * @param originalFileName * @param newFileName */ private static void rename(Context context, String originalFileName, String newFileName) { File originalFile = context.getFileStreamPath(originalFileName); if (originalFile.exists()) { Log.d("SavingHelper", "renaming " + originalFileName + " size " + originalFile.length() + " to " + newFileName); File newFile = new File(originalFile.getParent(), newFileName); if (newFile.exists()) { context.deleteFile(newFileName); } originalFile.renameTo(newFile); } }
From source file:Main.java
public static byte[] readFromFile(String fileName, int offset, int len) { if (fileName == null) { return null; }/*w w w.j a v a 2 s .c o m*/ File file = new File(fileName); if (!file.exists()) { Log.i(TAG, "readFromFile: file not found"); return null; } if (len == -1) { len = (int) file.length(); } Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len)); if (offset < 0) { Log.e(TAG, "readFromFile invalid offset:" + offset); return null; } if (len <= 0) { Log.e(TAG, "readFromFile invalid len:" + len); return null; } if (offset + len > (int) file.length()) { Log.e(TAG, "readFromFile invalid file len:" + file.length()); return null; } byte[] b = null; try { RandomAccessFile in = new RandomAccessFile(fileName, "r"); b = new byte[len]; in.seek(offset); in.readFully(b); in.close(); } catch (Exception e) { Log.e(TAG, "readFromFile : errMsg = " + e.getMessage()); e.printStackTrace(); } return b; }
From source file:Main.java
public static void writeStreamToFile(InputStream is, File file) { FileOutputStream fos = null;/* w ww. j a va 2s . co m*/ try { fos = new FileOutputStream(file); byte[] buffer = new byte[4096]; int length = 0; while ((length = is.read(buffer)) != -1) { fos.write(buffer, 0, length); fos.flush(); } Log.d("tg", "FileUtils writeStreamToFile successed..."); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:Main.java
public static String findBuildPropValueOf(String prop) { String mBuildPath = "/system/build.prop"; String DISABLE = "disable"; String value = null;/*from w ww . ja v a2s .co m*/ try { //create properties construct and load build.prop Properties mProps = new Properties(); mProps.load(new FileInputStream(mBuildPath)); //get the property value = mProps.getProperty(prop, DISABLE); Log.d("TAG", String.format("Helpers:findBuildPropValueOf found {%s} with the value (%s)", prop, value)); } catch (IOException ioe) { Log.d("TAG", "failed to load input stream"); } catch (NullPointerException npe) { //swallowed thrown by ill formatted requests } if (value != null) { return value; } else { return DISABLE; } }
From source file:Main.java
public static byte[] readFromFile(String fileName, int offset, int len) { if (fileName == null) { return null; }/*from w ww . ja v a 2 s .c om*/ File file = new File(fileName); if (!file.exists()) { Log.i(TAG, "readFromFile: file not found"); return null; } if (len == -1) { len = (int) file.length(); } Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len)); if (offset < 0) { Log.e(TAG, "readFromFile invalid offset:" + offset); return null; } if (len <= 0) { Log.e(TAG, "readFromFile invalid len:" + len); return null; } if (offset + len > (int) file.length()) { Log.e(TAG, "readFromFile invalid file len:" + file.length()); return null; } byte[] b = null; try { RandomAccessFile in = new RandomAccessFile(fileName, "r"); b = new byte[len]; // in.seek(offset); in.readFully(b); in.close(); } catch (Exception e) { Log.e(TAG, "readFromFile : errMsg = " + e.getMessage()); e.printStackTrace(); } return b; }
From source file:Main.java
public static String getDaysWithoutYear(String srcDate) { SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formater = new SimpleDateFormat("MM/dd"); Date date = null;//from www.j ava 2 s . co m try { parserSDF.setTimeZone(TimeZone.getTimeZone("UTC")); date = parserSDF.parse(srcDate); } catch (ParseException e) { Log.d(TAG, e.getMessage()); } return formater.format(date); }
From source file:Main.java
public static String readDeviceUUID(String devicePath) { String uuid = null;//from w ww.ja v a2s . c o m File root = new File(devicePath); if (root.isDirectory()) { File uFile = new File(devicePath, ".uuid"); FileReader reader = null; try { char[] buffer = new char[36]; reader = new FileReader(uFile); reader.read(buffer, 0, buffer.length); uuid = new String(buffer); Log.d(TAG, "readDeviceUUID uuid:" + uuid); return uuid; } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } } return uuid; }
From source file:Main.java
public static void printMultiLog(String... msg) { if (msg != null && DEBUG) { sb.setLength(0);//from w w w . j a va2s . c om if (msg.length > 0) { for (String aMsg : msg) { sb.append(aMsg); sb.append(" "); } } else { sb.append("empty printMultiLog please check"); } Log.d(TAG, sb.toString()); } }
From source file:Main.java
public static void scaleBitmaps(SparseArray<Bitmap> bitmapMap, float scale) { for (int i = 0; i < bitmapMap.size(); i++) { int key = bitmapMap.keyAt(i); Log.d("BitmapUtil", "scaleBitmaps: " + key); Bitmap bitmap = bitmapMap.get(key); bitmapMap.put(i, scaleBitmap(bitmap, scale)); }// w w w. j a v a2 s . c o m }