List of usage examples for android.util Log w
public static int w(String tag, String msg, Throwable tr)
From source file:Main.java
public static void w(String tag, String msg, Throwable tr) { if (DEBUG) { Log.w(tag, msg, tr); } }
From source file:Main.java
public static byte[] bitmapToByteArray(Bitmap bitmap, int imageQuality) { ByteArrayOutputStream bos = null; try {//from ww w . j av a 2 s. c o m bos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, imageQuality, bos); return bos.toByteArray(); } finally { if (bos != null) { try { bos.close(); } catch (IOException e) { Log.w(TAG, "Failed to close ByteArrayOutputStream", e); // Ignore exception } } } }
From source file:Main.java
public static int findProcessId(String command) { int procId = -1; try {/*from w w w . ja v a 2 s.c o m*/ procId = findProcessIdWithPidOf(command); if (procId == -1) procId = findProcessIdWithPS(command); } catch (Exception e) { try { procId = findProcessIdWithPS(command); } catch (Exception e2) { Log.w("the-onion-phone", "Unable to get proc id for: " + command, e2); } } return procId; }
From source file:Main.java
public static void LOGW(final String tag, String message, Throwable cause) { Log.w(tag, message, cause); }
From source file:Main.java
public static String createExternalStoragePrivateFile(Context appCtx, InputStream is, String fileName) { File file = new File(appCtx.getExternalFilesDir(null), fileName); try {// w w w . j a va2s .co m //InputStream is = appCtx.getResources().openRawResource(R.raw.calipso); OutputStream os = new FileOutputStream(file); byte[] data = new byte[is.available()]; is.read(data); os.write(data); is.close(); os.close(); } catch (IOException e) { // Unable to create file, likely because external storage is // not currently mounted. Log.w("ExternalStorage", "Error writing " + file, e); } return file.getPath(); }
From source file:Main.java
public static int getColorAttribute(Context context, int key, int defaultColor) { if (sColorAttrsArray.get(key) != null) { return sColorAttrsArray.get(key); }/*from w w w . j a v a 2 s .c o m*/ TypedArray a = null; try { int[] attr = new int[] { key }; int indexOfAttrBackgroundColor = 0; a = context.obtainStyledAttributes(attr); sColorAttrsArray.put(key, a.getColor(indexOfAttrBackgroundColor, defaultColor)); } catch (Exception e) { sColorAttrsArray.put(key, defaultColor); if (DEBUG) Log.w(TAG, "unexpected exception", e); } finally { if (a != null) a.recycle(); } return sColorAttrsArray.get(key); }
From source file:Main.java
public static void recycleSilently(Bitmap bitmap) { if (bitmap == null) return;/*from ww w . j a v a2 s . co m*/ try { bitmap.recycle(); } catch (Throwable t) { Log.w(TAG, "unable recycle bitmap", t); } }
From source file:Main.java
public static void closeSilently(Closeable c) { if (c == null) return;//w w w.ja va 2s . c o m try { c.close(); } catch (Throwable t) { Log.w(TAG, "fail to close", t); } }
From source file:Main.java
public static void closeSilently(Closeable c) { if (c == null) return;/*from w w w . j av a 2s .c om*/ try { c.close(); } catch (IOException t) { Log.w(TAG, "close fail ", t); } }
From source file:Main.java
/** * Helper method to open a content URI and returns the ParcelFileDescriptor. * * @param context {@link Context} in interest. * @param uriString the content URI to open. * @return ParcelFileDescriptor of the content URI, or NULL if the file does not exist. *//* www . j a v a 2 s . c om*/ private static ParcelFileDescriptor getParcelFileDescriptor(Context context, String uriString) { ContentResolver resolver = context.getContentResolver(); Uri uri = Uri.parse(uriString); ParcelFileDescriptor pfd = null; try { pfd = resolver.openFileDescriptor(uri, "r"); } catch (FileNotFoundException e) { Log.w(TAG, "Cannot find content uri: " + uriString, e); } catch (SecurityException e) { Log.w(TAG, "Cannot open content uri: " + uriString, e); } catch (IllegalArgumentException e) { Log.w(TAG, "Unknown content uri: " + uriString, e); } catch (IllegalStateException e) { Log.w(TAG, "Unknown content uri: " + uriString, e); } return pfd; }