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.emorym.android_pusher.Pusher.java

public Channel subscribe(String channelName) {
    Channel c = new Channel(channelName);

    if (mWebSocket != null && mWebSocket.isConnected()) {
        try {/*from   www  .  j a  v  a  2s .  co  m*/
            sendSubscribeMessage(c);
        } catch (Exception e) {
            if (Log.isLoggable(TAG, DEBUG))
                Log.d(TAG, "Exception sending subscribe message", e);
        }
    }

    channels.put(channelName, c);

    return c;
}

From source file:com.android.mms.widget.MmsWidgetProvider.java

public static void notifyDatasetChanged(Context context) {
    if (Log.isLoggable(LogTag.WIDGET, Log.VERBOSE)) {
        Log.v(TAG, "notifyDatasetChanged");
    }//from w w  w .  ja v a2 s  .  c  o m
    final Intent intent = new Intent(ACTION_NOTIFY_DATASET_CHANGED);
    context.sendBroadcast(intent);
}

From source file:com.example.android.synchronizednotifications.DismissListener.java

@Override // ConnectionCallbacks
public void onConnected(Bundle bundle) {
    final Uri dataItemUri = new Uri.Builder().scheme(WEAR_URI_SCHEME).path(Constants.BOTH_PATH).build();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Deleting Uri: " + dataItemUri.toString());
    }//ww  w.  ja  va  2s . c o  m
    Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri).setResultCallback(this);
}

From source file:com.infine.android.devoxx.ui.TwitterFragment2.java

/** {@inheritDoc} */
public void onQueryComplete(int token, Object cookie, Cursor cursor) {
    if (getActivity() == null) {
        return;/*  www .  j ava 2s  . c  o m*/
    }

    if (token == TweetsQuery._TOKEN) {
        onTweetsQueryComplete(cursor);
    } else {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d("SessionsFragment/onQueryComplete", "Query complete, Not Actionable: " + token);
        }
        cursor.close();
    }
}

From source file:com.samsung.multiwindow.MultiWindow.java

/**
 * This method will initialize Multiwindow on the device.
 * // w  ww . j  av a  2s  . c  o m
 */
private int intializeMultiwindow() {

    if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
        Log.d(TAG, "Inside intializeMultiwindow,");
    }
    mMultiWindow = new SMultiWindow();

    try {
        mMultiWindow.initialize(this.cordova.getActivity());
    } catch (SsdkUnsupportedException e) {
        return e.getType();
    }

    return INIT_SUCCESS;
}

From source file:com.google.android.apps.iosched.ui.MapFragment.java

private void runJs(String js) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Loading javascript:" + js);
    }//from ww  w .j a  va 2  s. c  om
    mWebView.loadUrl("javascript:" + js);
}

From source file:com.pindroid.client.PinboardApi.java

/**
 * Attempts to authenticate to Pinboard using a legacy Pinboard account.
 * /*from  ww w . j  ava  2s.com*/
 * @param username The user's username.
 * @param password The user's password.
 * @param handler The hander instance from the calling UI thread.
 * @param context The context of the calling Activity.
 * @return The boolean result indicating whether the user was
 *         successfully authenticated.
 * @throws  
 */
public static String pinboardAuthenticate(String username, String password) {
    final HttpResponse resp;

    Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME);
    builder.authority(PINBOARD_AUTHORITY);
    builder.appendEncodedPath(AUTH_TOKEN_URI);
    Uri uri = builder.build();

    HttpGet request = new HttpGet(String.valueOf(uri));

    DefaultHttpClient client = (DefaultHttpClient) HttpClientFactory.getThreadSafeClient();

    CredentialsProvider provider = client.getCredentialsProvider();
    Credentials credentials = new UsernamePasswordCredentials(username, password);
    provider.setCredentials(SCOPE, credentials);

    try {
        resp = client.execute(request);
        if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

            final HttpEntity entity = resp.getEntity();

            InputStream instream = entity.getContent();
            SaxTokenParser parser = new SaxTokenParser(instream);
            PinboardAuthToken token = parser.parse();
            instream.close();

            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Successful authentication");
                Log.v(TAG, "AuthToken: " + token.getToken());
            }

            return token.getToken();
        } else {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Error authenticating" + resp.getStatusLine());
            }
            return null;
        }
    } catch (final IOException e) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "IOException when getting authtoken", e);
        }
        return null;
    } catch (ParseException e) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "ParseException when getting authtoken", e);
        }
        return null;
    } finally {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "getAuthtoken completing");
        }
    }
}

From source file:com.example.android.elizachat.ResponderService.java

private void processIncoming(String text) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Received: " + text);
    }/*w  w w .  ja  va2  s .c  o  m*/
    mLastResponse = mResponder.elzTalk(text);
    String line = TextUtils.isEmpty(text) ? mLastResponse : text + "\n" + mLastResponse;

    // Send a new line of conversation to update the Activity, unless the incoming text was
    // empty.
    if (!TextUtils.isEmpty(text)) {
        broadcastMessage(line);
    }
    NotificationManagerCompat.from(this).cancelAll();
    showNotification();
    mCompleteConversation.append("\n" + line);
}

From source file:com.android.car.trust.CarBleTrustAgent.java

@Override
public void onTrustTimeout() {
    super.onTrustTimeout();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onTrustTimeout(): timeout expired");
    }/*  w ww  . ja v a2  s.c  o m*/
}

From source file:edu.cmu.android.restaurant.authentication.NetworkUtilities.java

/**
 * Connects to the Voiper server, authenticates the provided username and
 * password./*w  ww.ja  va  2  s .c o  m*/
 * 
 * @param username
 *            The user's username
 * @param password
 *            The user's password
 * @param handler
 *            The hander instance from the calling UI thread.
 * @param context
 *            The context of the calling Activity.
 * @return boolean The boolean result indicating whether the user was
 *         successfully authenticated.
 */
public static boolean authenticate(String username, String password, Handler handler, final Context context) {
    final HttpResponse resp;

    final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair(PARAM_USERNAME, username));
    params.add(new BasicNameValuePair(PARAM_PASSWORD, password));
    HttpEntity entity = null;
    try {
        entity = new UrlEncodedFormEntity(params);
    } catch (final UnsupportedEncodingException e) {
        // this should never happen.
        throw new AssertionError(e);
    }
    final HttpPost post = new HttpPost(AUTH_URI);
    post.addHeader(entity.getContentType());
    post.setEntity(entity);
    maybeCreateHttpClient();

    try {
        resp = mHttpClient.execute(post);
        if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Successful authentication");
            }
            sendResult(true, handler, context);
            return true;
        } else {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Error authenticating" + resp.getStatusLine());
            }
            sendResult(false, handler, context);
            return false;
        }
    } catch (final IOException e) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "IOException when getting authtoken", e);
        }
        sendResult(false, handler, context);
        return false;
    } finally {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "getAuthtoken completing");
        }
    }
}