List of usage examples for android.util Log e
public static int e(String tag, String msg, Throwable tr)
From source file:Main.java
public static void putString(Context context, String category, String key, String value) { try {// w w w . j a v a 2 s .c o m SharedPreferences setMyPref = context.getSharedPreferences(category, Activity.MODE_WORLD_READABLE); SharedPreferences.Editor prefsEditor = setMyPref.edit(); prefsEditor.putString(key, value); prefsEditor.commit(); } catch (Exception e) { Log.e(TAG, "Error when getString, return defaultValue ", e); } }
From source file:Main.java
public static X509Certificate loadCertificate(String certificate) { try {/*from w ww . jav a 2s . c om*/ return loadCertificate(certificate.getBytes()); } catch (Exception ex) { Log.e(TAG, "Failed to parse certificate", ex); } return null; }
From source file:Main.java
private static void print(StackTraceElement element, Object message, Throwable error) { String className = element.getClassName(); className = className.substring(className.lastIndexOf(".") + 1); String tag = className + '.' + element.getMethodName() + '(' + element.getFileName() + ':' + element.getLineNumber() + ')'; String text = toString(message); if (error != null) { Log.e("[KakaCache]", tag + "\n\t" + text, error); } else {/* ww w . jav a 2s . c om*/ Log.e("[KakaCache]", tag + "\n\t" + text); } }
From source file:Main.java
public static void startEmailIntent(Context context, String emailAddress) { try {/*from ww w . j a v a 2 s .c om*/ Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailAddress }); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting email intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app for sending emails!", Toast.LENGTH_SHORT) .show(); } }
From source file:Main.java
/** * Get application name.//from w w w. jav a 2s . co m * * @return */ public static String getApplicationName(Context context) { String name = "?"; try { PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); name = context.getString(pi.applicationInfo.labelRes); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Package name not found", e); } ; return name; }
From source file:Main.java
public static void log(String message, Throwable tr) { Log.e(TAG, message, tr); }
From source file:Main.java
@Deprecated private static Long[] getIdArray(String serializedTree) { ArrayList<Long> ids = new ArrayList<>(); String[] digitsOnly = serializedTree.split("[\\[\\],\\s]"); // Split on [ ] , or whitespace chars for (String idString : digitsOnly) { try {//w ww . j ava 2 s . c o m if (!TextUtils.isEmpty(idString)) { ids.add(Long.parseLong(idString)); } } catch (NumberFormatException e) { Log.e("widget-subtasks", "error parsing id " + idString, e); } } return ids.toArray(new Long[ids.size()]); }
From source file:Main.java
public static int getAppCode(Context context) { int versionCode = 0; try {/*from w w w . j a v a2 s. co m*/ // ---get the package info--- PackageManager pm = context.getPackageManager(); PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); versionCode = pi.versionCode; if (versionCode <= 0) { return 0; } } catch (Exception e) { Log.e("VersionInfo", "Exception", e); } return versionCode; }
From source file:Main.java
public static String getSystemProperty(String propName) { String line = ""; BufferedReader input = null;/* w w w . ja v a 2 s. c o m*/ try { Process p = Runtime.getRuntime().exec("getprop " + propName); input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024); line = input.readLine(); input.close(); } catch (IOException ex) { Log.e(TAG, "Unable to read sysprop " + propName, ex); return null; } finally { if (input != null) { try { input.close(); } catch (IOException e) { Log.e(TAG, "Exception while closing InputStream", e); } } } return line; }
From source file:Main.java
public static String getAppVersionName(Context context) { String versionName = ""; try {//from w w w .j a va2 s . com // ---get the package info--- PackageManager pm = context.getPackageManager(); PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); versionName = pi.versionName; if (versionName == null || versionName.length() <= 0) { return null; } } catch (Exception e) { Log.e("VersionInfo", "Exception", e); } return versionName; }