List of usage examples for android.util Log e
public static int e(String tag, String msg)
From source file:Main.java
public static int getVersionCode(Context context) { try {/*from w ww . j a v a 2 s . c o m*/ PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pInfo.versionCode; } catch (NameNotFoundException nnfe) { Log.e(TAG, "Error finding version code: " + nnfe); } return -1; }
From source file:Main.java
public static String getVersionName(Context context) { try {// w w w .j a va 2 s .co m PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pInfo.versionName; } catch (NameNotFoundException nnfe) { Log.e(TAG, "Error finding version code: " + nnfe); } return ""; }
From source file:Main.java
public static int numberBounce(PrintWriter out, BufferedReader in) { try {/*w ww . java2s . co m*/ String theString = in.readLine(); if (theString != null) { int num = Integer.parseInt(theString); ++num; out.println("" + num); return num; } } catch (IOException e) { Log.e("NUMBER_BOUNCE_METHOD", e.getMessage()); } return -1; }
From source file:Main.java
private static HttpURLConnection addHeaders(HttpURLConnection urlConnection, Map<String, String> headers) { try {/* ww w . ja v a 2 s . c o m*/ for (Map.Entry<String, String> entry : headers.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); urlConnection.setRequestProperty(key, value); } } catch (Exception ex) { Log.e("addHeader ", ex.getMessage()); } return urlConnection; }
From source file:Main.java
public static String readSingleLineFromFile(InputStream in, int lineNumber) { BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line = ""; try {/* www. j a v a2 s . co m*/ for (int i = 0; i < lineNumber - 1; ++i) { br.readLine(); } line = br.readLine(); } catch (IOException e) { Log.e("LineParseError", "Could not read line"); } try { in.reset(); } catch (IOException e) { Log.e("LineParser", "Could not reset InputStream"); } return line; }
From source file:Main.java
/** * Method to trim log messages for error * * @param TAG Tag for the message// w w w.ja v a2s . c o m * @param message Message to log */ public static void e(String TAG, String message) { int maxLogSize = 1000; for (int index = 0; index <= message.length() / maxLogSize; index++) { int start = index * maxLogSize; int end = (index + 1) * maxLogSize; end = end > message.length() ? message.length() : end; Log.e(TAG, message.substring(start, end)); } }
From source file:Main.java
public static void deleteFilesByDirectory(File directory) { // LogUtil.e("TAG", "deleteFiles--directory:"+directory); // LogUtil.e("TAG", "deleteFiles--exists:"+directory.exists()); // LogUtil.e("TAG", "deleteFiles--isDirectory:"+directory.isDirectory()); if (directory != null && directory.exists() && directory.isDirectory()) { for (File item : directory.listFiles()) { Log.e("TAG", "deleteFiles--item:" + item); Log.e("TAG", "deleteFiles--item.isdir:" + item.isDirectory()); if (item != null && item.isDirectory()) { for (File itemsec : item.listFiles()) { itemsec.delete();//from ww w.j a v a 2 s .c om } } item.delete(); } } }
From source file:Main.java
public static void setLongPreferences(Context context, String name, long value) { try {/* w ww . java 2 s.c o m*/ SharedPreferences.Editor editor = context .getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit(); editor.putLong(name, value); editor.commit(); } catch (Exception e) { Log.e("datautils", e.getMessage()); remove(context, name); } }
From source file:Main.java
/** * (java)write to file/*from w w w. j av a2s. co m*/ * * @param str * @param path */ public static void writeFile(String str, File file) { FileOutputStream out; try { file.createNewFile(); out = new FileOutputStream(file, false); String infoToWrite = str; out.write(infoToWrite.getBytes()); out.close(); } catch (IOException e) { Log.e("", "write error!"); } }
From source file:Main.java
public static byte[] hexToBytes(String hex) { try {/*from w w w.j a v a 2 s . com*/ int length = hex.length(); byte[] bytes = new byte[length / 2]; for (int i = 0; i < length; i += 2) { bytes[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) + Character.digit(hex.charAt(i + 1), 16)); } return bytes; } catch (Exception e) { Log.e(TAG, "Got Exception: " + e.toString()); return new byte[0]; } }