Example usage for android.util Log isLoggable

List of usage examples for android.util Log isLoggable

Introduction

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

Prototype

public static native boolean isLoggable(String tag, int level);

Source Link

Document

Checks to see whether or not a log for the specified tag is loggable at the specified level.

Usage

From source file:com.google.android.dialer.provider.DialerProvider.java

private String executeHttpRequest(Uri uri) throws IOException {
    String charset = null;//from ww  w  .  j  ava2s .c  om

    if (Log.isLoggable("DialerProvider", Log.VERBOSE)) {
        Log.v("DialerProvider", "executeHttpRequest(" + uri + ")");
    }

    try {
        URLConnection conn = new URL(uri.toString()).openConnection();
        conn.setRequestProperty("User-Agent", mUserAgent);

        InputStream inputStream = conn.getInputStream();
        charset = getCharsetFromContentType(conn.getContentType());

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        byte[] buf = new byte[1000];
        while (true) {
            int len = inputStream.read(buf);
            if (len <= 0) {
                break;
            }
            outputStream.write(buf, 0, len);
        }

        inputStream.close();
        outputStream.flush();

        return new String(outputStream.toByteArray(), charset);
    } catch (UnsupportedEncodingException e) {
        Log.w("DialerProvider", "Invalid charset: " + charset, e);
    } catch (IOException e) {
        // TODO: Didn't find anything that goes here in byte-code
    }

    // TODO: Is this appropriate?
    return null;
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * Stack Trace  ?.//w ww.  j  a  va 2  s  .c om
 * 
 * @param clazz  ??  Class.
 * @param level  .
 * @param msg .
 */
public static void stackTrace(final Class<?> clazz, final int level, final String msg) {
    if (Log.isLoggable(TAG, level)) {
        Thread th = Thread.currentThread();
        StackTraceElement[] stack = th.getStackTrace();

        StringBuilder sb = new StringBuilder();
        if (msg != null && !"".equals(msg)) {
            sb.append(msg).append("\n");
        }
        for (StackTraceElement element : stack) {
            if (!"getStackTrace".equals(element.getMethodName())
                    && !"stackTrace".equals(element.getMethodName())) {
                sb.append("\tat ").append(element.toString()).append("\n");
            }
        }
        Log.println(level, TAG, LogUtil.getClassLineNumber(clazz) + " - " + sb.toString());
    }
}

From source file:com.geocine.mms.com.android.mms.transaction.HttpUtils.java

private static AndroidHttpClient createHttpClient(Context context) {
    String userAgent = MmsConfig.getUserAgent();
    AndroidHttpClient client = AndroidHttpClient.newInstance(userAgent, context);
    HttpParams params = client.getParams();
    HttpProtocolParams.setContentCharset(params, "UTF-8");

    // set the socket timeout
    int soTimeout = MmsConfig.getHttpSocketTimeout();

    if (Log.isLoggable(LogTag.TRANSACTION, Log.DEBUG)) {
        Log.d(TAG,/*w  w  w  .  j av a  2 s  . co m*/
                "[HttpUtils] createHttpClient w/ socket timeout " + soTimeout + " ms, " + ", UA=" + userAgent);
    }
    HttpConnectionParams.setSoTimeout(params, soTimeout);
    return client;
}

From source file:com.example.everyoneassist.Layout.PercentLayoutHelper.java

private static PercentLayoutInfo setTextSizeSupportVal(TypedArray array, PercentLayoutInfo info) {
    //textSizePercent 
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(array,
            R.styleable.PercentLayout_Layout_layout_textSizePercent, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }//  w w w . java2s  .  com
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    return info;
}

From source file:com.lyp.percent.PercentLayoutHelper.java

private static PercentLayoutInfo setTextSizeSupportVal(TypedArray array, PercentLayoutInfo info) {
    //textSizePercent ?
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(array,
            R.styleable.PercentLayout_Layout_layout_textSizePercent, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }/*from w  ww  .j  a  v  a 2s.  co  m*/
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    return info;
}

From source file:caesar.feng.framework.percentlayout.PercentLayoutHelper.java

private static PercentLayoutInfo setTextSizeSupportVal(TypedArray array, PercentLayoutInfo info) {
    //textSizePercent 
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(array,
            R.styleable.PercentLayout_Layout_layout_textSizePercent, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }//w  w  w. j  ava2s  .co  m
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    return info;
}

From source file:com.example.recycleviewtest.PercentLayoutHelper.java

private static PercentLayoutInfo setTextSizeSupportVal(TypedArray array, PercentLayoutInfo info) {
    //textSizePercent ???
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(array,
            R.styleable.PercentLayout_Layout_layout_textSizePercent, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }/*from  www . j  a v a  2s  .  c om*/
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    return info;
}

From source file:android.percent.support.PercentLayoutHelper.java

private static PercentLayoutInfo setTextSizeSupportVal(TypedArray array, PercentLayoutInfo info) {
    //textSizePercent ???        PercentLayoutInfo.PercentVal percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_textSizePercent, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }//www.  j av a  2 s .c  om
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    return info;
}

From source file:com.neuwill.support.PercentLayoutHelper.java

private static PercentLayoutInfo setTextSizeSupportVal(TypedArray array, PercentLayoutInfo info) {
    // textSizePercent 
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(array,
            R.styleable.PercentLayout_Layout_layout_textSizePercent, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }//from   ww  w  .j  ava2 s .  co  m
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    return info;
}

From source file:com.concentriclivers.mms.com.android.mms.transaction.MessagingNotification.java

/**
 * Checks to see if there are any "unseen" messages or delivery
 * reports and builds a sorted (by delivery date) list of unread notifications.
 *
 * @param context the context to use/*w  w w.  j a  v  a  2s  .co m*/
 * @param newMsgThreadId The thread ID of a new message that we're to notify about; if there's
 *  no new message, use THREAD_NONE. If we should notify about multiple or unknown thread IDs,
 *  use THREAD_ALL.
 * @param isStatusMessage
 */
public static void blockingUpdateNewMessageIndicator(Context context, long newMsgThreadId,
        boolean isStatusMessage) {
    // TDH
    Log.d("NotificationDebug", "blockingUpdateNewMessageIndicator: newMsgThreadId: " + newMsgThreadId);

    synchronized (sCurrentlyDisplayedThreadLock) {
        if (newMsgThreadId > 0 && newMsgThreadId == sCurrentlyDisplayedThreadId) {
            if (DEBUG) {
                Log.d(TAG,
                        "blockingUpdateNewMessageIndicator: newMsgThreadId == "
                                + "sCurrentlyDisplayedThreadId so NOT showing notification,"
                                + " but playing soft sound. threadId: " + newMsgThreadId);
            }
            // TDH
            Log.d("NotificationDebug", "Calling playInConversationNotificationSound");

            playInConversationNotificationSound(context);
            return;
        }
    }
    // TDH
    Log.d("NotificationDebug", "Calling sNotificationSet.clear();");

    sNotificationSet.clear();

    MmsSmsDeliveryInfo delivery = null;
    Set<Long> threads = new HashSet<Long>(4);

    int count = 0;
    addMmsNotificationInfos(context, threads);
    addSmsNotificationInfos(context, threads);

    // TDH
    Log.d("NotificationDebug", "Cancelling notification");

    cancelNotification(context, NOTIFICATION_ID);
    if (!sNotificationSet.isEmpty()) {
        if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            Log.d(TAG,
                    "blockingUpdateNewMessageIndicator: count=" + count + ", newMsgThreadId=" + newMsgThreadId);
        }
        // TDH
        Log.d("NotificationDebug", "Calling updateNotification()");

        updateNotification(context, newMsgThreadId != THREAD_NONE, threads.size());
    }

    // And deals with delivery reports (which use Toasts). It's safe to call in a worker
    // thread because the toast will eventually get posted to a handler.
    delivery = getSmsNewDeliveryInfo(context);
    if (delivery != null) {
        delivery.deliver(context, isStatusMessage);
    }
}