List of usage examples for android.util Log e
public static int e(String tag, String msg)
From source file:Main.java
public static void e(String strFormat, Object... args) { if ((strFormat == null) || (strFormat.length() == 0)) return;/*from w w w .j av a 2s .c om*/ String strMessage = strFormat; if (args.length != 0) strMessage = String.format(strFormat, args); int nLine = Thread.currentThread().getStackTrace()[3].getLineNumber(); String strClass = Thread.currentThread().getStackTrace()[3].getClassName(); String strMethod = Thread.currentThread().getStackTrace()[3].getMethodName(); strClass = strClass.substring(strClass.lastIndexOf(".") + 1); String str = String.format("[%5d] %-50s %s", nLine, strClass + ":" + strMethod, strMessage); Log.e(m_strTag, str); write("[E]", m_strTag, str); }
From source file:Main.java
public static String getLocalIpAddress() { try {/*from w w w.j a va 2s.c o m*/ Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); while (en.hasMoreElements()) { NetworkInterface intf = en.nextElement(); String name = intf.getName(); if (name.compareTo("eth0") == 0 || name.compareTo("wlan0") == 0) { Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); while (enumIpAddr.hasMoreElements()) { InetAddress inetAddress = enumIpAddr.nextElement(); if (inetAddress.getClass() == Inet4Address.class) { return inetAddress.getHostAddress(); } } } } } catch (SocketException ex) { Log.e("MY", ex.toString()); } return null; }
From source file:Main.java
public static void showProgressDialog(Activity context, int stringResId) { try {/*from www . j ava2s .c om*/ showProgressDialog(context, null, context.getResources().getString(stringResId)); } catch (Exception e) { Log.e(TAG, "showProgressDialog showProgressDialog(Context context, null, context.getResources().getString(stringResId));"); } }
From source file:Main.java
public static String getSHA256(String mykey) { try {/* ww w. j a va 2 s. com*/ MessageDigest digest = java.security.MessageDigest.getInstance("SHA256"); digest.update(mykey.getBytes(Charset.forName("UTF-8"))); return bytesToHex(digest.digest()).toLowerCase(); } catch (NoSuchAlgorithmException e) { Log.e(TAG, "SHA hash exception: " + e.toString()); return null; } }
From source file:Main.java
/** * Sets the preference.//from w ww . j a va 2s.c o m * * @param key the key * @param value the value */ public static void setPreference(String key, Object value, Context c) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(c); // The SharedPreferences editor - must use commit() to submit changes SharedPreferences.Editor editor = preferences.edit(); if (value instanceof Integer) editor.putInt(key, ((Integer) value).intValue()); else if (value instanceof Long) editor.putLong(key, ((Long) value)); else if (value instanceof String) editor.putString(key, (String) value); else if (value instanceof Boolean) editor.putBoolean(key, (Boolean) value); else if (value instanceof Float) editor.putFloat(key, (Float) value); editor.commit(); Log.e("Preference set: ", key + " => " + value); }
From source file:Main.java
/** * Logs the given message and shows an error alert dialog with it. * //w w w . j a v a 2 s. c om * @param activity activity * @param tag log tag to use * @param message message to log and show or {@code null} for none */ public static void logAndShowError(Activity activity, String tag, String message) { String errorMessage = getErrorMessage(message); Log.e(tag, errorMessage); showErrorInternal(activity, errorMessage); }
From source file:Main.java
public static String getAppVersionCode(Context context) { String ret = ""; try {/*from w w w . java 2 s .c o m*/ int version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; ret = String.valueOf(version); } catch (Exception e) { Log.e(TAG, "error getting version number"); } return ret; }
From source file:com.prey.ReflectionsUtils.java
public static Class getJSONObjectClass(JSONObject object) { Class clazz = null;/*from www. j a va 2 s. c om*/ try { String className = (String) object.get(ATTRIBUTE_CLASS); clazz = Class.forName(className); } catch (JSONException e) { Log.e("Reflections Utils", "Ocurrio un error al obtener la clase del JSONObject"); } catch (ClassNotFoundException e) { Log.e("Reflections Utils", "La clase que se intenta crear no Existe!"); } return clazz; }
From source file:Main.java
/** * Return the absolute path to the hub database. * * @return path The path to the db as a string *//* www . j a va 2 s . com*/ private static String getDbPath() { if (Debug) Log.i(TAG, "getDBPath() called."); String path = Environment.getExternalStorageDirectory().getPath() + "/" + BASE_DIR; File dbDir = new File(path); if (!dbDir.isDirectory()) { try { if (Debug) Log.i(TAG, "Trying to create " + path); dbDir.mkdirs(); } catch (Exception e) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); Log.e(TAG, result.toString()); } } return path; }
From source file:Main.java
public static void log(Object object, String msg, boolean debug, int level) { if (level < CURRENT_DEBUG_LEVEL) { return;// w w w .ja va 2 s. c om } else { if (DEBUG && debug) { String name = object.getClass().getSimpleName(); switch (level) { case DEBUG_LEVEL_VERBOSE: Log.v(TAG, name + ": " + msg); break; case DEBUG_LEVEL_DEBUG: Log.d(TAG, name + ": " + msg); break; case DEBUG_LEVEL_ERROR: Log.e(TAG, name + ": " + msg); break; default: break; } } } }