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

private static int getNullCheckInt(JSONObject o, String value) {
    try {/*from  w ww .  j  a  v  a 2 s  .c  om*/
        if (o.isNull(value)) {
            return -1;
        } else {
            return o.getInt(value);
        }
    } catch (JSONException je) {
        Log.e(TAG, "Failed to parse JSON", je);
    }
    return 0;
}

From source file:Main.java

private static synchronized void removeFile() {
    try {//from   www. ja v  a2s .  c o  m
        File file = new File(TWEETS_FILE_PATH);
        if (file.exists()) {
            file.delete();
        }
    } catch (Exception er) {
        Log.e(tag, "Error removing file", er);
    }
}

From source file:Main.java

/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance() {
    Camera c = null;/*from   w w  w.  j av  a  2 s.  co  m*/
    try {
        c = Camera.open(); // attempt to get a Camera instance
    } catch (Exception e) {
        // Camera is not available (in use or does not exist)
        Log.e("ch.getCI", "Failed to get camera!", e);
    }
    return c; // returns null if camera is unavailable
}

From source file:Main.java

/**
 * Convenience function - closes the given stream (can be any Closable), catching and logging exceptions
 * @param stream a Closeable to close// www  .  j  ava2 s  .c o m
 */
static public void close(final Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            Log.e("Vespucci", "Problem closing", e);
        }
    }
}

From source file:Main.java

public static int str2int(String s, int defVal) {
    if (s.equals("N/A"))
        return defVal;
    try {//from w w w  .  j  a  va2s  .co m
        s = s.trim();
        s = s.contains(" ") ? s.split(" ")[0] : s;
        return NumberFormat.getInstance(Locale.ENGLISH).parse(s).intValue();
    } catch (Exception err) {
        Log.e("str2int", s, err);
        return defVal;
    }
}

From source file:Main.java

public static String createTbutlerFolder() {
    String folder = "/sdcard/tbutler";
    if (checkState()) {
        try {//from   ww  w  . j  a  va 2 s.  c  o m
            File file = new File(folder);
            if (!file.exists()) {
                file.mkdir();
            }
        } catch (Exception er) {
            Log.e(tag, "error creating folder", er);
        }
    }
    return folder + "/";
}

From source file:Main.java

public static void startWebIntent(Context context, String url) {
    try {/*from   w  w w . ja v  a2 s. c o  m*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        context.startActivity(intent);
    } catch (Exception ex) {
        Log.e(TAG, "Error starting url intent.", ex);
        Toast.makeText(context, "Sorry, we couldn't find any app for viewing this url!", Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:Main.java

/**
 * Convenience function - closes the given stream (can be any Closable), catching and logging exceptions
 * @param stream a Closeable to close//from w  w w .  j a  va  2  s. c o  m
 */
static public void close(final Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            Log.e("SavingHelper", "Problem closing", e);
        }
    }
}

From source file:Main.java

/**
 * Executes single ping and return/*from www . ja v  a 2s . c o  m*/
 * @param ip - address to ping
 * @return true - ping was successful
 */
public static boolean ping(String ip) {
    Runtime runtime = Runtime.getRuntime();

    try {
        Process process = runtime.exec("/system/bin/ping -c 1 " + ip);
        return process.waitFor() == 0;

    } catch (Exception ignore) {
        Log.e(TAG, "Error while", ignore);
    }

    return false;
}

From source file:Main.java

public static Object deserializeObject(byte[] b) {
    try {/*  w w w.  j  a  v  a2  s.  co m*/
        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(b));
        Object object = in.readObject();
        in.close();

        return object;
    } catch (ClassNotFoundException cnfe) {
        Log.e("deserializeObject", "class not found error", cnfe);

        return null;
    } catch (IOException ioe) {
        Log.e("deserializeObject", "io error", ioe);

        return null;
    }
}