Example usage for android.util Log v

List of usage examples for android.util Log v

Introduction

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

Prototype

public static int v(String tag, String msg) 

Source Link

Document

Send a #VERBOSE log message.

Usage

From source file:Main.java

public static void v(String tag, String msg) {
    if (DEBUG) {
        Log.v(tag, msg);
    }
}

From source file:Main.java

private static void log(String tag, int level, String msg, Throwable tr) {
    if (isLog) {/*  ww w. j a v a2s  .co  m*/
        switch (level) {
        case Log.VERBOSE:
            if (tr == null) {
                Log.v(tag, msg);
            } else {
                Log.v(tag, msg, tr);
            }
            break;
        case Log.INFO:
            if (tr == null) {
                Log.i(tag, msg);
            } else {
                Log.i(tag, msg, tr);
            }
            break;
        case Log.DEBUG:
            if (tr == null) {
                Log.d(tag, msg);
            } else {
                Log.d(tag, msg, tr);
            }
            break;
        case Log.WARN:
            if (tr == null) {
                Log.w(tag, msg);
            } else {
                Log.w(tag, msg, tr);
            }
            break;
        case Log.ERROR:
            if (tr == null) {
                Log.e(tag, msg, tr);
            } else {
                Log.e(tag, msg, tr);
            }
            break;
        }
    }
}

From source file:Main.java

public static boolean isRunningOnEmulator(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String networkOperator = tm.getNetworkOperatorName();

    Log.v(TAG, "Network operator is " + networkOperator);

    if (networkOperator.equals("Android")) {
        Log.i(TAG, "Running on emulator.");
        return true;
    }//from w  ww .ja va2  s. com

    Log.i(TAG, "Running on real device.");
    return false;
}

From source file:Main.java

public static void v(String message) {
    if (LEVEL <= VERBOSE) {
        StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[3];
        String tag = getDefaultTag(stackTraceElement);
        Log.v(tag, getLogInfo(stackTraceElement) + message);
    }/*from  w w w. j  av  a 2 s .c  o m*/
}

From source file:Main.java

protected static void trace(String message) {
    if (logVerbose) {
        Log.v(LOGTAG, message);
    }
}

From source file:Main.java

public static Object getObjectField(Object obj, String fieldName) {
    try {/*from w  w  w  .j a  v a2 s  . co m*/
        return findField(obj.getClass(), fieldName).get(obj);
    } catch (IllegalAccessException e) {
        // should not happen
        Log.v("test", e.getMessage());
        throw new IllegalAccessError(e.getMessage());
    } catch (IllegalArgumentException e) {
        throw e;
    }
}

From source file:Main.java

public static String getSimID() {
    // TODO Auto-generated method stub
    Log.v(TAG, "getSimID() called");
    String simID = "";
    try {/*from  w  w  w  .  j av  a 2 s. com*/
        FileInputStream is = new FileInputStream(SIMCARD_PATH);
        DataInputStream dis = new DataInputStream(is);
        simID = dis.readLine();
        simID = simID.trim();
        is.close();
        dis.close();
        return simID;
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        Log.v(TAG, "getSimID exception: do not have a SIM Card!", e);
        return "123456";
    } catch (IOException e) {
        // TODO Auto-generated catch block
        Log.v(TAG, "getSimID exception: read IOException", e);
        return "";
    }

}

From source file:Main.java

public static boolean isPastWeek(Date date) {
    Date currentDate = new Date();
    Date firstTimeOfWeek = firstTimeOfWeek(currentDate);

    float currentSecond = secondFromMilisecond(firstTimeOfWeek.getTime());
    float actuallySecond = secondFromMilisecond(date.getTime());
    float delta = actuallySecond - currentSecond;
    Log.v("Time currentDate", "" + currentDate);
    Log.v("Time currentSecond", "" + firstTimeOfWeek);
    Log.v("Time actuallySecond", "" + date);
    Log.v("Time delta", "" + delta);
    if (delta >= 0 && delta < 60 * 60 * 24 * 7) {
        return true;
    }/*  w  w w .j a v  a2s .com*/
    return false;
}

From source file:Main.java

public static boolean isPastMonth(Date date) {
    Date currentDate = new Date();
    Date firstTimeOfMonth = firstTimeOfMonth(currentDate);

    float currentSecond = secondFromMilisecond(firstTimeOfMonth.getTime());
    float actuallySecond = secondFromMilisecond(date.getTime());
    float delta = actuallySecond - currentSecond;
    Log.v("Time currentDate", "" + currentDate);
    Log.v("Time currentSecond", "" + firstTimeOfMonth);
    Log.v("Time actuallySecond", "" + date);
    Log.v("Time delta", "" + delta);
    if (delta > 0 && delta <= 60 * 60 * 24 * 30) {
        return true;
    }//ww  w  .j a va  2  s  . c  om
    return false;
}

From source file:Main.java

/**
 * Converts time to a string, e.g. "1:59:30"
 * or "3.6" or "5:33"./*from  w w w. j  av a  2s .  c om*/
 *
 * @param milliseconds Time in milliseconds since start of meeting
 * @return String formatted time interval string in "H:MM:SS" format.
 */
public static String timeToHMMSS(long milliseconds) {
    Log.v(TAG, "timeToHMMSS(" + milliseconds + ")");

    int seconds = (int) (milliseconds % 60_000) / 1000;
    int minutes = (int) (milliseconds / 60_000) % 60;
    int hours = (int) (milliseconds / 3600_000);

    String hms;
    if (hours >= 1) {
        hms = String.format(Locale.getDefault(), "%d:%02d:%02d", hours, minutes, seconds);
    } else if (minutes >= 1) {
        hms = String.format(Locale.getDefault(), "%d:%02d", minutes, seconds);
    } else {
        hms = String.format(Locale.getDefault(), "%d", seconds);
    }
    return hms;
}