Example usage for android.util Log e

List of usage examples for android.util Log e

Introduction

In this page you can find the example usage for android.util Log e.

Prototype

public static int e(String tag, String msg, Throwable tr) 

Source Link

Document

Send a #ERROR log message and log the exception.

Usage

From source file:Main.java

/**
 * Return a byte[] containing the bytes in a given base64 string, or null if this is not a valid
 * base64 string./*  www  .j a  v a 2  s.com*/
 */
public static byte[] getBytesFromBase64(String base64) {
    try {
        return Base64.decode(base64, Base64.DEFAULT);
    } catch (Exception e) {
        Log.e(LOGTAG, "exception decoding bitmap from data URI: " + base64, e);
    }

    return null;
}

From source file:Main.java

/**
 * Read all from InputStream/*w  w w .  j  a  va  2s .  c  om*/
 * @param is Stream to read from
 * @param size Guess the size of InputStream contents, give negative for the automatic
 * @return
 */
public static String readFromInputStream(InputStream is, int size) {
    try {
        ByteArrayOutputStream os;
        if (size <= 0) {
            os = new ByteArrayOutputStream();
        } else {
            os = new ByteArrayOutputStream(size);
        }
        byte buffer[] = new byte[4096];
        int len;
        while ((len = is.read(buffer)) != -1) {
            os.write(buffer, 0, len);
        }
        return os.toString("UTF-8");
    } catch (IOException e) {
        Log.e("SOAP", "readFromInputStream", e);
        return "";
    }
}

From source file:Main.java

public static String getCRC32(File file) {
    CRC32 crc32 = new CRC32();
    CheckedInputStream checkedinputstream = null;
    String crc = null;//w w  w.  j  a v  a2s  .  c o  m
    try {
        checkedinputstream = new CheckedInputStream(new FileInputStream(file), crc32);
        byte[] buf = new byte[1024];
        while (checkedinputstream.read(buf) >= 0) {
        }
        crc = Long.toHexString(crc32.getValue()).toUpperCase();
    } catch (Exception e) {
        Log.w(TAG, e);
        Log.e("WxException", e.getMessage(), e);
    } finally {
        if (checkedinputstream != null) {
            try {
                checkedinputstream.close();
            } catch (IOException e) {
            }
        }
    }
    return crc;
}

From source file:Main.java

public static String loadAssetsText(AssetManager assetManager, String fileName, String charset) {
    String text = null;/*from   ww w  .j a v  a 2 s. c  o m*/
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(assetManager.open(fileName), charset));
        StringBuilder sb = new StringBuilder();
        while ((text = br.readLine()) != null) {
            sb.append(text);
        }
        text = sb.toString();
    } catch (IOException e) {
        Log.e(TAG, e.getMessage(), e);
    }
    return text;
}

From source file:Main.java

public static Bitmap decodeResource(Context context, int id, BitmapFactory.Options options) {
    Resources resources = context.getResources();
    try {/*from   w w  w .  j  a  v  a 2  s  .  c o m*/
        return BitmapFactory.decodeResource(resources, id, options);
    } catch (OutOfMemoryError e) {
        Log.e(LOGTAG, "decodeResource() OOM! Resource id=" + id, e);
        return null;
    }
}

From source file:Main.java

public static void LOGE(final String tag, String message, Throwable cause) {
    if (LOGGING_ENABLED) {
        Log.e(tag, message, cause);
    }/*from w  ww .ja v a  2  s. c  o  m*/
}

From source file:Main.java

/**
 * Get a Date object corresponding to the provided ISO 8601 string
 *
 * @param date the date string/* w  w  w. java2 s.  c  om*/
 * @return a Date object corresponding to the provided ISO 8601 string, or null
 * if the string cannot be parsed.
 */
public static Date getDateFromIso8601String(String date) {
    initFormatter();
    try {
        return mIso8601WithMillisFormat.parse(date);
    } catch (ParseException e) {
        try {
            return mIso8601Format.parse(date);
        } catch (ParseException e1) {
            Log.e(TAG, e1.getMessage(), e1);
        }
    }
    return null;
}

From source file:Main.java

/**
 * error log/*from   w ww .  java  2 s  .  co m*/
 * @param tag tag
 * @param msg log msg
 * @param e exception
 */
public static void e(String tag, String msg, Exception e) {
    if (LOG_ENABLE) {
        Log.e(tag, buildMsg(msg), e);
    }
}

From source file:Main.java

public static int getExifOrientation(String filepath) {
    int degree = 0;
    try {/*from w  w w.ja va2s.  com*/
        ExifInterface exif = new ExifInterface(filepath);
        if (exif != null) {
            int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
            if (orientation != -1) {
                switch (orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    degree = 90;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    degree = 180;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_270:
                    degree = 90;
                    break;
                }
            }
        }
        return degree;
    } catch (IOException ex) {
        Log.e("ExifOrientation", "cannot read exif", ex);
    }
    return degree;
}

From source file:Main.java

public static String readFile(String path) {
    try {/*  ww w . jav  a  2s.  c om*/
        FileInputStream in = new FileInputStream(path);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte buffer[] = new byte[1024];
        int count = 0;

        while ((count = in.read(buffer)) != -1) {
            if (out != null) {
                out.write(buffer, 0, count);
            }
        }

        return out.toString();

    } catch (FileNotFoundException e) {
        Log.e(TAG, "File not found: " + path, e);

    } catch (IOException e) {
        Log.e(TAG, "Error while reading file: " + path, e);
    }

    return null;
}