List of usage examples for android.util Log d
public static int d(String tag, String msg, Throwable tr)
From source file:Main.java
public static String getApplicationVersion(Context ctx) { try {//from w w w . j av a 2 s . co m return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { Log.d(TAG, "", e); return null; } }
From source file:Main.java
public static void LOGD(final String tag, String message, Throwable cause) { if (LOGGING_ENABLED) { if (Log.isLoggable(tag, Log.DEBUG)) { Log.d(tag, message, cause); }//from w ww. ja v a2 s . c o m } }
From source file:Main.java
public static void invokeObjMethod(Object ob, String methodName, int value1, int value2) { if (ob == null) { return;/*from w ww . j ava 2 s . co m*/ } try { Method method = ob.getClass().getMethod(methodName, int.class, int.class); method.invoke(ob, value1, value2); } catch (Exception e) { Log.d(TAG, "invokeObjMethod error", e); } }
From source file:Main.java
public static void d(String tag, String msg, Throwable tr) { if (DEBUG) { Log.d(tag, msg, tr); } }
From source file:Main.java
public static String getUrlStatus(String ss) { String st = ""; try {//from ww w . j a va2 s . c o m st = URLDecoder.decode(ss.replaceAll("\\+", "-000000000000000-"), "utf-8") .replaceAll("-000000000000000-", "+"); } catch (UnsupportedEncodingException e) { Log.d("decode", ss, e); } return st.substring("file:".length(), st.length()).replaceAll("///", "/").replaceAll("//", "/"); }
From source file:Main.java
public static byte[] hexStringToBytes(String hex) { byte[] bytes = new byte[hex.length() / 2]; int j = 0;//w ww .j a va 2 s . co m for (int i = 0; i < hex.length(); i += 2) { try { String hexByte = hex.substring(i, i + 2); Integer I = new Integer(0); I = Integer.decode("0x" + hexByte); int k = I.intValue(); bytes[j++] = new Integer(k).byteValue(); } catch (NumberFormatException e) { Log.d(LOG_TAG, "hexStringToBytes", e); return bytes; } catch (StringIndexOutOfBoundsException e) { Log.d(LOG_TAG, "hexStringToBytes", e); return bytes; } } return bytes; }
From source file:Main.java
/** * Returns the version name of the current app * * @param context an app context to retrieve the package manager and package name * @return the version name or "unknown" if the package name (of this current app) is not found *///from w w w .ja v a 2 s.c om public static String getVersionName(Context context) { String versionName = "unknown"; try { versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES).versionName; } catch (PackageManager.NameNotFoundException ignore) { Log.d("NoTils", "Version name not found, Paul has a hat to eat.", ignore); } return versionName; }
From source file:Main.java
private static String encryptText(char[] plaintext, Cipher cipher) { byte[] plaintextBytes = charArrayToByteArray(plaintext); byte[] ciphertext = {}; try {// ww w . j a v a 2 s . com ciphertext = cipher.doFinal(plaintextBytes); } catch (Exception e) { Log.d(LOG_TAG, "encryptText", e); } //turn into hex so storage as a string is possible (db) return toHexString(ciphertext); }
From source file:Main.java
/** * Writes an image to file// w w w . j a v a 2 s. c o m * * @param src the image to write * @param file the destination file * @return true in case of success, false otherwise */ private static boolean writeBitmapToFile(Bitmap src, File file) { FileOutputStream out = null; try { out = new FileOutputStream(file); src.compress(Bitmap.CompressFormat.JPEG, 70, out); // bmp is your Bitmap instance return true; } catch (Exception e) { Log.d(TAG, "Error writing image", e); e.printStackTrace(); } finally { try { if (out != null) { out.close(); } } catch (IOException e) { Log.d(TAG, "Error writing image", e); } } return false; }
From source file:Main.java
public static void doWait(Object syncObj) { synchronized (syncObj) { try {// ww w .j av a 2 s. c o m syncObj.wait(); } catch (InterruptedException e) { Log.d("", "", e); } } }