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:com.google.android.apps.santatracker.util.SantaLog.java

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

From source file:Main.java

/**
 * @param message     Message to display
 * @param type        [Log.Error, Log.Warn, ...]
 * @param shouldPrint value that comes from Preferences which allows the user to decide if debug info should be printed to logcat. Error info will ALWAYS be displayed despite this value
 *//*w  w w .  jav  a 2  s  .  c  o m*/
public static void debugFunc(String message, int type, boolean shouldPrint) {
    // errors must always be displayed
    if (type == Log.ERROR) {
        Log.e(LOG_TAG, message);
    } else if (shouldPrint) {
        switch (type) {
        case Log.DEBUG:
            Log.d(LOG_TAG, message);
            break;
        case Log.INFO:
            Log.i(LOG_TAG, message);
            break;
        case Log.VERBOSE:
            Log.v(LOG_TAG, message);
            break;
        case Log.WARN:
            Log.w(LOG_TAG, message);
            break;
        default:
            Log.v(LOG_TAG, message);
            break;
        }
    }
}

From source file:Main.java

private static boolean CopyFile(Context context, String pathName) {

    boolean isCopyCompleted = false;

    InputStream inputStream = null;
    OutputStream outputStream = null;

    try {//  w  w w  .j a v  a  2 s .c  o m
        inputStream = context.getResources().getAssets().open(pathName);
        File outFile = new File(context.getCacheDir(), pathName);
        if (!outFile.exists()) {
            outFile.createNewFile();
        }

        outputStream = new FileOutputStream(outFile);

        byte[] buffer = new byte[4096];
        int bytesRead;
        // read from is to buffer
        while ((bytesRead = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, bytesRead);
            Log.v("", "data..." + bytesRead);
        }

        isCopyCompleted = true;
        inputStream.close();
        // flush OutputStream to write any buffered data to file
        outputStream.flush();
        outputStream.close();

    } catch (IOException e) {
        isCopyCompleted = false;
        e.printStackTrace();
    }
    return isCopyCompleted;

}

From source file:Main.java

public static String HttpGet(String url) {
    HttpClient client = new DefaultHttpClient();
    StringBuilder builder = new StringBuilder();
    HttpGet myget = new HttpGet(url);
    try {/*  w w  w  . j  av  a2s.  co  m*/
        HttpResponse response = client.execute(myget);
        BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

        for (String s = reader.readLine(); s != null; s = reader.readLine()) {
            builder.append(s);
        }

        char cr = 65279;
        String t = String.valueOf(cr);
        String resultString = builder.toString();
        resultString = resultString.replace("\t", "").replace(t, "");

        return resultString;

    } catch (Exception e) {
        Log.v("url response", "false");
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

/**
 * Retrieves the GCM registration Id. Will require a new one if the app is
 * updated or if the regId is expired./*from ww w .j  a  v a  2s .  com*/
 *
 * @param context
 * @return
 */
public static String getRegistrationId(Context context) {
    String regId = getGcmRegistrationIdFromPreferences(context);

    if (TextUtils.isEmpty(regId)) {
        Log.v(TAG, "No GCM Registration Id found.");
        return "";
    }
    // Check if app was updated. if so, it must clear registration id to
    // avoid a race condition if GCM sends a message
    int registeredVersion = getGcmAppVersion(context);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion || isRegistrationExpired(context)) {
        // TODO - Add isRegistrationExpired?
        Log.v(TAG, "App version changed.");
        return "";
    }
    return regId;
}

From source file:Main.java

private static void print(int mode, final String tag, String msg) {
    if (!isPrint) {
        return;/*  w w w. j av  a  2 s  .c  om*/
    }
    if (msg == null) {
        Log.e(tag, MSG);
        return;
    }
    switch (mode) {
    case Log.VERBOSE:
        Log.v(tag, msg);
        break;
    case Log.DEBUG:
        Log.d(tag, msg);
        break;
    case Log.INFO:
        Log.i(tag, msg);
        break;
    case Log.WARN:
        Log.w(tag, msg);
        break;
    case Log.ERROR:
        Log.e(tag, msg);
        break;
    default:
        Log.d(tag, msg);
        break;
    }
}

From source file:Main.java

public static String getContactName(Context context, String number) {

    String name = null;// ww  w. j  ava 2  s.c  o  m

    // define the columns I want the query to return
    String[] projection = new String[] { Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
            ? ContactsContract.Contacts.DISPLAY_NAME_PRIMARY
            : ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.PhoneLookup._ID };

    // encode the phone number and build the filter URI
    Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));

    // query time
    Cursor cursor = context.getContentResolver().query(contactUri, projection, null, null, null);

    if (cursor != null) {
        if (cursor.moveToFirst()) {
            name = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
            Log.v("getContactName", "Started uploadcontactphoto: Contact Found @ " + number);
            Log.v("getContactName", "Started uploadcontactphoto: Contact name  = " + name);
        } else {
            Log.v("getContactName", "Contact Not Found @ " + number);
        }
        cursor.close();
    }
    return name;
}

From source file:Main.java

/**
 * Check whether a ratio is valid./*  w  w  w  .j  ava  2s.  com*/
 * @param    ratio   The string containing the proposed ratio.
 * @param    split   The amount of shares the ratio should be split in. 
 *          Pass less than 2 to avoid checking shares. 
 * @return    Whether ratio is valid for required shares.
 */
public static boolean validRatio(String ratio, int split) {
    boolean result = false;
    if (ratio.matches("^[0-9][0-9]*:[[0-9]:]*[0-9]*[0-9]$")) {
        Log.v(TAG, "Checking ratio " + ratio + " results follow...");
        Log.i(TAG, "RATIO PATTERN MATCHED");
        if (split > 1) {
            String[] ratios = ratio.split(":");
            if (ratios.length == split) {
                Log.i(TAG, "RATIO IS VALID, hoorah!");
                result = true;
            } else {
                Log.w(TAG, "INVALID AMOUNT OF SHARES, RATIO INVALID");
            }
        } else {
            result = true;
        }
    } else {
        Log.w(TAG, "INVALID RATIO");
    }
    return result;
}

From source file:Main.java

public static void invalidateGlobalRegion(View view, RectF childBounds) {
    //childBounds.offset(view.getTranslationX(), view.getTranslationY());
    if (DEBUG_INVALIDATE)
        Log.v(TAG, "-------------");
    while (view.getParent() != null && view.getParent() instanceof View) {
        view = (View) view.getParent();
        view.getMatrix().mapRect(childBounds);
        view.invalidate((int) Math.floor(childBounds.left), (int) Math.floor(childBounds.top),
                (int) Math.ceil(childBounds.right), (int) Math.ceil(childBounds.bottom));
        if (DEBUG_INVALIDATE) {
            Log.v(TAG,/*from w w w  .ja v  a  2 s  .  c o  m*/
                    "INVALIDATE(" + (int) Math.floor(childBounds.left) + "," + (int) Math.floor(childBounds.top)
                            + "," + (int) Math.ceil(childBounds.right) + ","
                            + (int) Math.ceil(childBounds.bottom));
        }
    }
}

From source file:Main.java

public static Calendar getCalendarForTime(int repeatMode, int dayOfWeek, int hour, int minute, int second) {
    Calendar calendarNow = Calendar.getInstance();
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, minute);
    calendar.set(Calendar.SECOND, second);
    calendar.set(Calendar.MILLISECOND, 0);
    if (repeatMode == 2) {
        int dayOfWeekAndroid = 0; // 7 stands for sunday for interface, but for android, sunday stands for 1.
        dayOfWeekAndroid = dayOfWeek % 7 + 1;
        calendar.set(Calendar.DAY_OF_WEEK, dayOfWeekAndroid);
    }/*from   ww  w.ja  va2s  . c  o  m*/

    // make sure the desire alarm time is in future.
    int tryCount = 0;
    int tryCountMax = 62;
    while (calendar.getTimeInMillis() < calendarNow.getTimeInMillis() && tryCount < tryCountMax) {
        if (repeatMode == 1) {
            calendar.add(Calendar.DAY_OF_YEAR, 1);
        } else if (repeatMode == 2) {
            calendar.add(Calendar.DAY_OF_YEAR, 7);
        }
        tryCount++;
    }
    Log.v("cpeng", "getCalendearForTime target info: " + calendar.toString());
    return calendar;
}