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) 

Source Link

Document

Send an #ERROR log message.

Usage

From source file:Main.java

/**
 * Force screen to turn on if the phone is asleep.
 *
 * @param context The current Context or Activity that this method is called from
 *///from w  w w  .j av a  2s . c  o m
public static void turnScreenOn(Activity context) {
    try {
        Window window = context.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
        window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
        window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    } catch (Exception ex) {
        Log.e("PercolateAndroidUtils", "Unable to turn on screen for activity " + context);
    }
}

From source file:Main.java

private static String getVerNameFromAssert(Context context) {

    String versionName = "";
    try {//ww  w.j a v a 2  s.com
        Properties pro = new Properties();
        InputStream is = context.getAssets().open("channel.properties");
        pro.load(is);
        String tmpVersionName = pro.getProperty("versionName");

        versionName = new String(tmpVersionName.getBytes("ISO-8859-1"), "UTF-8");

        is.close();
        is = null;
    } catch (Exception e) {
        versionName = "";
        Log.e(TAG, "AppConfig.loadVersion have Exception e = " + e.getMessage());
    }
    return versionName;

}

From source file:Main.java

public static void e(String tag, String message) {
    Log.e(tag, message);
}

From source file:Main.java

/**
 * error log//  w  w w.j a v a 2  s  .c  o m
 * @param tag tag
 * @param msg msg
 */
public static void e(String tag, String msg) {
    if (LOG_ENABLE) {
        Log.e(tag, buildMsg(msg));
    }
}

From source file:Main.java

/**
 * Read Access token from Json object that we got from O8 Auth server.
 * // ww  w . j a  va 2s .co  m
 */
private static String getAccessToken(JsonReader reader) throws IOException {
    String text = null;

    try {
        reader.beginObject();
        while (reader.hasNext()) {
            String name = reader.nextName();
            if (name.equals("access_token")) {
                text = reader.nextString();
                break;
            }
        }

        //reader.endObject();
    } catch (IOException ex) {
        Log.e(TAG, ex.getStackTrace().toString());
    }
    return text;
}

From source file:Main.java

/**
 * (java) read from file/*from  ww  w .  ja  v  a2  s  .c om*/
 * 
 * @param path
 * @return
 */
public static String readFile(File file) {
    String str = "";
    FileInputStream in;
    try {
        in = new FileInputStream(file);
        int length = (int) file.length();
        byte[] temp = new byte[length];
        in.read(temp, 0, length);
        str = EncodingUtils.getString(temp, FILE_ENCODING);
        in.close();
    } catch (IOException e) {
        Log.e("", "read error!");

    }
    return str;
}

From source file:Main.java

public static String getIMSI(Context context) {
    String imsi = "";
    try {//from ww  w . j a  v a 2  s  .c o m
        TelephonyManager phoneManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        imsi = phoneManager.getSubscriberId();
        Log.v(TAG, imsi);
    } catch (Exception e) {
        Log.e(TAG, "getIMSI error!");
        imsi = "";
    }

    if (imsi == null) {
        imsi = "";
    }
    return imsi;
}

From source file:Main.java

public static byte[] readFromFile(String fileName, int offset, int len) {
    if (fileName == null) {
        return null;
    }//from  w ww.  j  a v a2s .c om

    File file = new File(fileName);
    if (!file.exists()) {
        Log.i(TAG, "readFromFile: file not found");
        return null;
    }

    if (len == -1) {
        len = (int) file.length();
    }

    Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));

    if (offset < 0) {
        Log.e(TAG, "readFromFile invalid offset:" + offset);
        return null;
    }
    if (len <= 0) {
        Log.e(TAG, "readFromFile invalid len:" + len);
        return null;
    }
    if (offset + len > (int) file.length()) {
        Log.e(TAG, "readFromFile invalid file len:" + file.length());
        return null;
    }

    byte[] b = null;
    try {
        RandomAccessFile in = new RandomAccessFile(fileName, "r");
        b = new byte[len];
        in.seek(offset);
        in.readFully(b);
        in.close();

    } catch (Exception e) {
        Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
        e.printStackTrace();
    }
    return b;
}

From source file:Main.java

public static byte[] readFromFile(String fileName, int offset, int len) {
    if (fileName == null) {
        return null;
    }//w w w  .ja  v a 2s . co m

    File file = new File(fileName);
    if (!file.exists()) {
        Log.i(TAG, "readFromFile: file not found");
        return null;
    }

    if (len == -1) {
        len = (int) file.length();
    }

    Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));

    if (offset < 0) {
        Log.e(TAG, "readFromFile invalid offset:" + offset);
        return null;
    }
    if (len <= 0) {
        Log.e(TAG, "readFromFile invalid len:" + len);
        return null;
    }
    if (offset + len > (int) file.length()) {
        Log.e(TAG, "readFromFile invalid file len:" + file.length());
        return null;
    }

    byte[] b = null;
    try {
        RandomAccessFile in = new RandomAccessFile(fileName, "r");
        b = new byte[len]; //
        in.seek(offset);
        in.readFully(b);
        in.close();

    } catch (Exception e) {
        Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
        e.printStackTrace();
    }
    return b;
}

From source file:Main.java

/**
 * Convert format date//from ww  w.j a  v a  2 s . co  m
 * @param String date
 * @param String from_format
 * @param String to_format
 * @return
 */
public static String convertFormatDate(String date, String from_format, String to_format) {
    SimpleDateFormat inputFormat = null;
    SimpleDateFormat outputFormat = null;
    Date formattedDate = null;

    try {
        inputFormat = new SimpleDateFormat(from_format);
        outputFormat = new SimpleDateFormat(to_format);
        formattedDate = inputFormat.parse(date);
    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
    }

    return outputFormat.format(formattedDate);
}