List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:org.dodgybits.shuffle.android.server.sync.SyncAlarmService.java
@Override protected void onHandleIntent(Intent intent) { long lastSyncDate = Preferences.getLastSyncLocalDate(this); long nextSyncDate = Math.max(System.currentTimeMillis() + 5000L, lastSyncDate + SYNC_PERIOD); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Next sync at " + new Date(nextSyncDate)); }//from w ww.ja va 2s. c o m AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent syncIntent = new Intent(this, SyncAlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.setRepeating(AlarmManager.RTC, nextSyncDate, SYNC_PERIOD, pendingIntent); // Release the wake lock provided by the WakefulBroadcastReceiver WakefulBroadcastReceiver.completeWakefulIntent(intent); }
From source file:Main.java
/** * Checks to see whether or not a log for the specified tag is loggable at the specified level. *//*from w w w . ja v a2 s. c o m*/ public static boolean isLoggable(String tag, int level) { if (MAX_ENABLED_LOG_LEVEL > level) { return false; } return Log.isLoggable(tag, level); }
From source file:com.github.mguidi.asyncop.AsyncOp.java
protected final void dispatchResult() { Intent intent = new Intent(mIdHelper); intent.putExtra(Constants.ARGS_ID_REQUEST, mIdRequest); intent.putExtra(Constants.ARGS_ARGS, mArgs); intent.putExtra(Constants.ARGS_RESULTS, mResult); if (!LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent)) { if (Log.isLoggable(Constants.LOG_TAG, Log.DEBUG)) { Log.d(Constants.LOG_TAG, "dispatch result missed"); }/*from ww w.j ava2s . c om*/ } }
From source file:com.example.android.wearable.timer.TimerNotificationService.java
@Override protected void onHandleIntent(Intent intent) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onHandleIntent called with intent: " + intent); }/*from w w w .j a v a 2 s . co m*/ String action = intent.getAction(); if (Constants.ACTION_SHOW_ALARM.equals(action)) { showTimerDoneNotification(); } else if (Constants.ACTION_DELETE_ALARM.equals(action)) { deleteTimer(); } else if (Constants.ACTION_RESTART_ALARM.equals(action)) { restartAlarm(); } else { throw new IllegalStateException("Undefined constant used: " + action); } }
From source file:com.android.mms.widget.MmsWidgetProvider.java
@Override public void onReceive(Context context, Intent intent) { if (Log.isLoggable(LogTag.WIDGET, Log.VERBOSE)) { Log.v(TAG, "onReceive intent: " + intent); }// ww w . jav a2 s . c o m String action = intent.getAction(); // The base class AppWidgetProvider's onReceive handles the normal widget intents. Here // we're looking for an intent sent by the messaging app when it knows a message has // been sent or received (or a conversation has been read) and is telling the widget it // needs to update. if (ACTION_NOTIFY_DATASET_CHANGED.equals(action)) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(context, MmsWidgetProvider.class)); // We need to update all Mms appwidgets on the home screen. appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.conversation_list); } else { super.onReceive(context, intent); } }
From source file:com.example.android.elizachat.ResponderService.java
@Override public void onCreate() { super.onCreate(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Chat Service started"); }/*ww w.ja va 2 s. co m*/ mResponder = new ElizaResponder(); mBroadcastManager = LocalBroadcastManager.getInstance(this); processIncoming(null); }
From source file:com.android.mms.widget.MmsWidgetProvider.java
/** * Update the widget appWidgetId/* w w w.j a va2 s .co m*/ */ private static void updateWidget(Context context, int appWidgetId) { if (Log.isLoggable(LogTag.WIDGET, Log.VERBOSE)) { Log.v(TAG, "updateWidget appWidgetId: " + appWidgetId); } RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); PendingIntent clickIntent; // Launch an intent to avoid ANRs final Intent intent = new Intent(context, MmsWidgetService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); remoteViews.setRemoteAdapter(appWidgetId, R.id.conversation_list, intent); remoteViews.setTextViewText(R.id.widget_label, context.getString(R.string.sms_app_label)); // Open Mms's app conversation list when click on header final Intent convIntent = new Intent(context, ConversationList.class); clickIntent = PendingIntent.getActivity(context, 0, convIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widget_header, clickIntent); // On click intent for Compose final Intent composeIntent = new Intent(context, ComposeMessageActivity.class); composeIntent.setAction(Intent.ACTION_SENDTO); clickIntent = PendingIntent.getActivity(context, 0, composeIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widget_compose, clickIntent); // On click intent for Conversation TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context); taskStackBuilder.addParentStack(ComposeMessageActivity.class); Intent msgIntent = new Intent(Intent.ACTION_VIEW); msgIntent.setType("vnd.android-dir/mms-sms"); taskStackBuilder.addNextIntent(msgIntent); remoteViews.setPendingIntentTemplate(R.id.conversation_list, taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)); AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews); }
From source file:com.DGSD.Teexter.UI.Recipient.RecipientAlternatesAdapter.java
/** * Get a HashMap of address to RecipientEntry that contains all contact * information for a contact with the provided address, if one exists. This * may block the UI, so run it in an async task. * //from www . j av a 2s . c o m * @param context * Context. * @param inAddresses * Array of addresses on which to perform the lookup. * @return HashMap<String,RecipientEntry> */ public static HashMap<String, RecipientEntry> getMatchingRecipients(Context context, String[] inAddresses) { int addressesSize = Math.min(MAX_LOOKUPS, inAddresses.length); String[] addresses = new String[addressesSize]; StringBuilder bindString = new StringBuilder(); // Create the "?" string and set up arguments. for (int i = 0; i < addressesSize; i++) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(inAddresses[i].toLowerCase()); addresses[i] = (tokens.length > 0 ? tokens[0].getAddress() : inAddresses[i]); bindString.append("?"); if (i < addressesSize - 1) { bindString.append(","); } } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Doing reverse lookup for " + addresses.toString()); } HashMap<String, RecipientEntry> recipientEntries = new HashMap<String, RecipientEntry>(); Cursor c = context.getContentResolver().query(Phone.CONTENT_URI, EmailQuery.PROJECTION, Email.ADDRESS + " IN (" + bindString.toString() + ")", addresses, null); if (c != null) { try { if (c.moveToFirst()) { do { String address = c.getString(EmailQuery.ADDRESS); recipientEntries.put(address, RecipientEntry.constructTopLevelEntry(c.getString(EmailQuery.NAME), c.getString(EmailQuery.ADDRESS), c.getInt(EmailQuery.ADDRESS_TYPE), c.getString(EmailQuery.ADDRESS_LABEL), c.getLong(EmailQuery.CONTACT_ID), c.getLong(EmailQuery.DATA_ID), c.getString(EmailQuery.PHOTO_THUMBNAIL_URI))); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Received reverse look up information for " + address + " RESULTS: " + " NAME : " + c.getString(EmailQuery.NAME) + " CONTACT ID : " + c.getLong(EmailQuery.CONTACT_ID) + " ADDRESS :" + c.getString(EmailQuery.ADDRESS)); } } while (c.moveToNext()); } } finally { c.close(); } } return recipientEntries; }
From source file:com.pindroid.client.NetworkUtilities.java
/** * Attempts to authenticate to Pinboard using a legacy Pinboard account. * //from w w w. j a v a 2 s . co 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 The boolean result indicating whether the user was * successfully authenticated. */ public static boolean pinboardAuthenticate(String username, String password) { final HttpResponse resp; Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME); builder.authority(PINBOARD_AUTHORITY); builder.appendEncodedPath("v1/posts/update"); 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) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Successful authentication"); } return true; } else { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Error authenticating" + resp.getStatusLine()); } return false; } } catch (final IOException e) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "IOException when getting authtoken", e); } return false; } finally { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "getAuthtoken completing"); } } }
From source file:com.example.android.wearable.timer.SetTimerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int paramLength = getIntent().getIntExtra(AlarmClock.EXTRA_LENGTH, 0); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "SetTimerActivity:onCreate=" + paramLength); }//from w w w.j av a2 s . co m if (paramLength > 0 && paramLength <= 86400) { long durationMillis = paramLength * 1000; setupTimer(durationMillis); finish(); return; } Resources res = getResources(); for (int i = 0; i < NUMBER_OF_TIMES; i++) { mTimeOptions[i] = new ListViewItem(res.getQuantityString(R.plurals.timer_minutes, i + 1, i + 1), (i + 1) * 60 * 1000); } setContentView(R.layout.timer_set_timer); // Initialize a simple list of countdown time options. mListView = (ListView) findViewById(R.id.times_list_view); ArrayAdapter<ListViewItem> arrayAdapter = new ArrayAdapter<ListViewItem>(this, android.R.layout.simple_list_item_1, mTimeOptions); mListView.setAdapter(arrayAdapter); mListView.setOnItemClickListener(this); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); }