List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.android.messaging.datamodel.NoConfirmationSmsSendService.java
@Override protected void onHandleIntent(final Intent intent) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent"); }/*from ww w . j a v a2 s. co m*/ final String action = intent.getAction(); if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent wrong action: " + action); } return; } final Bundle extras = intent.getExtras(); if (extras == null) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Called to send SMS but no extras"); } return; } // Get all possible extras from intent final String conversationId = intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID); final String selfId = intent.getStringExtra(EXTRA_SELF_ID); final boolean requiresMms = intent.getBooleanExtra(UIIntents.UI_INTENT_EXTRA_REQUIRES_MMS, false); final String message = getText(intent, Intent.EXTRA_TEXT); final String subject = getText(intent, Intent.EXTRA_SUBJECT); final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID); final Uri intentUri = intent.getData(); final String recipients = intentUri != null ? MmsUtils.getSmsRecipients(intentUri) : null; if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Both conversationId and recipient(s) cannot be empty"); } return; } if (extras.getBoolean("showUI", false)) { startActivity(new Intent(this, ConversationListActivity.class)); } else { if (TextUtils.isEmpty(message)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Message cannot be empty"); } return; } // TODO: it's possible that a long message would require sending it via mms, // but we're not testing for that here and we're sending the message as an sms. if (TextUtils.isEmpty(conversationId)) { InsertNewMessageAction.insertNewMessage(subId, recipients, message, subject); } else { MessageData messageData = null; if (requiresMms) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Auto-sending MMS message in conversation: " + conversationId); } messageData = MessageData.createDraftMmsMessage(conversationId, selfId, message, subject); } else { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Auto-sending SMS message in conversation: " + conversationId); } messageData = MessageData.createDraftSmsMessage(conversationId, selfId, message); } InsertNewMessageAction.insertNewMessage(messageData); } UpdateMessageNotificationAction.updateMessageNotification(); } }
From source file:com.aimfire.main.MainActivity.java
@Override protected void onNewIntent(Intent intent) { boolean isMyMedia = intent.getBooleanExtra(MainConsts.EXTRA_MSG, false); mTabPosition = isMyMedia ? TAB_INDEX_MY_MEDIA : TAB_INDEX_SHARED_MEDIA; if (BuildConfig.DEBUG) Log.d(TAG, "onNewIntent: selected position=" + mTabPosition); }
From source file:com.android.deskclock.alarms.AlarmStateManager.java
public static void handleIntent(Context context, Intent intent) { final String action = intent.getAction(); LogUtils.v("AlarmStateManager received intent " + intent); if (CHANGE_STATE_ACTION.equals(action)) { Uri uri = intent.getData();/*from w ww . ja va 2 s .c o m*/ AlarmInstance instance = AlarmInstance.getInstance(context.getContentResolver(), AlarmInstance.getId(uri)); if (instance == null) { LogUtils.e("Can not change state for unknown instance: " + uri); return; } int globalId = getGlobalIntentId(context); int intentId = intent.getIntExtra(ALARM_GLOBAL_ID_EXTRA, -1); int alarmState = intent.getIntExtra(ALARM_STATE_EXTRA, -1); if (intentId != globalId) { LogUtils.i("IntentId: " + intentId + " GlobalId: " + globalId + " AlarmState: " + alarmState); // Allows dismiss/snooze requests to go through if (!intent.hasCategory(ALARM_DISMISS_TAG) && !intent.hasCategory(ALARM_SNOOZE_TAG)) { LogUtils.i("Ignoring old Intent"); return; } } if (intent.getBooleanExtra(FROM_NOTIFICATION_EXTRA, false)) { if (intent.hasCategory(ALARM_DISMISS_TAG)) { Events.sendAlarmEvent(R.string.action_dismiss, R.string.label_notification); } else if (intent.hasCategory(ALARM_SNOOZE_TAG)) { Events.sendAlarmEvent(R.string.action_snooze, R.string.label_notification); } } if (alarmState >= 0) { setAlarmState(context, instance, alarmState); } else { registerInstance(context, instance, true); } } else if (SHOW_AND_DISMISS_ALARM_ACTION.equals(action)) { Uri uri = intent.getData(); AlarmInstance instance = AlarmInstance.getInstance(context.getContentResolver(), AlarmInstance.getId(uri)); if (instance == null) { LogUtils.e("Null alarminstance for SHOW_AND_DISMISS"); // dismiss the notification final int id = intent.getIntExtra(AlarmNotifications.EXTRA_NOTIFICATION_ID, -1); if (id != -1) { NotificationManagerCompat.from(context).cancel(id); } return; } long alarmId = instance.mAlarmId == null ? Alarm.INVALID_ID : instance.mAlarmId; Intent viewAlarmIntent = Alarm.createIntent(context, DeskClock.class, alarmId); viewAlarmIntent.putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.ALARM_TAB_INDEX); viewAlarmIntent.putExtra(AlarmClockFragment.SCROLL_TO_ALARM_INTENT_EXTRA, alarmId); viewAlarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(viewAlarmIntent); deleteInstanceAndUpdateParent(context, instance); } }
From source file:com.nononsenseapps.feeder.ui.FeedFragment.java
public FeedFragment() { // Listens on sync broadcasts mSyncReceiver = new BroadcastReceiver() { @Override/*from w w w .ja va 2 s . c o m*/ public void onReceive(Context context, Intent intent) { if (RssSyncAdapter.SYNC_BROADCAST.equals(intent.getAction())) { onSyncBroadcast(intent.getBooleanExtra(RssSyncAdapter.SYNC_BROADCAST_IS_ACTIVE, false)); } } }; }
From source file:it.feio.android.omninotes.async.DataBackupIntentService.java
synchronized private void exportData(Intent intent) { // Gets backup folder String backupName = intent.getStringExtra(INTENT_BACKUP_NAME); File backupDir = StorageHelper.getBackupDir(backupName); // Directory clean in case of previously used backup name StorageHelper.delete(this, backupDir.getAbsolutePath()); // Directory is re-created in case of previously used backup name (removed above) backupDir = StorageHelper.getBackupDir(backupName); // Database backup exportDB(backupDir);/* w w w . j av a2s. c om*/ // exportNotes(backupDir); // Attachments backup exportAttachments(backupDir); // Settings if (intent.getBooleanExtra(INTENT_BACKUP_INCLUDE_SETTINGS, true)) { exportSettings(backupDir); } // Notification of operation ended String title = getString(R.string.data_export_completed); String text = backupDir.getPath(); createNotification(intent, this, title, text, backupDir); }
From source file:com.androidinspain.deskclock.alarms.AlarmStateManager.java
public static void handleIntent(Context context, Intent intent) { final String action = intent.getAction(); LogUtils.v("AlarmStateManager received intent " + intent); if (CHANGE_STATE_ACTION.equals(action)) { Uri uri = intent.getData();/*from www. j ava2 s .co m*/ AlarmInstance instance = AlarmInstance.getInstance(context.getContentResolver(), AlarmInstance.getId(uri)); if (instance == null) { LogUtils.e("Can not change state for unknown instance: " + uri); return; } int globalId = DataModel.getDataModel().getGlobalIntentId(); int intentId = intent.getIntExtra(ALARM_GLOBAL_ID_EXTRA, -1); int alarmState = intent.getIntExtra(ALARM_STATE_EXTRA, -1); if (intentId != globalId) { LogUtils.i("IntentId: " + intentId + " GlobalId: " + globalId + " AlarmState: " + alarmState); // Allows dismiss/snooze requests to go through if (!intent.hasCategory(ALARM_DISMISS_TAG) && !intent.hasCategory(ALARM_SNOOZE_TAG)) { LogUtils.i("Ignoring old Intent"); return; } } if (intent.getBooleanExtra(FROM_NOTIFICATION_EXTRA, false)) { if (intent.hasCategory(ALARM_DISMISS_TAG)) { Events.sendAlarmEvent(com.androidinspain.deskclock.R.string.action_dismiss, com.androidinspain.deskclock.R.string.label_notification); } else if (intent.hasCategory(ALARM_SNOOZE_TAG)) { Events.sendAlarmEvent(com.androidinspain.deskclock.R.string.action_snooze, com.androidinspain.deskclock.R.string.label_notification); } } if (alarmState >= 0) { setAlarmState(context, instance, alarmState); } else { registerInstance(context, instance, true); } } else if (SHOW_AND_DISMISS_ALARM_ACTION.equals(action)) { Uri uri = intent.getData(); AlarmInstance instance = AlarmInstance.getInstance(context.getContentResolver(), AlarmInstance.getId(uri)); if (instance == null) { LogUtils.e("Null alarminstance for SHOW_AND_DISMISS"); // dismiss the notification final int id = intent.getIntExtra(AlarmNotifications.EXTRA_NOTIFICATION_ID, -1); if (id != -1) { NotificationManagerCompat.from(context).cancel(id); } return; } long alarmId = instance.mAlarmId == null ? Alarm.INVALID_ID : instance.mAlarmId; final Intent viewAlarmIntent = Alarm.createIntent(context, DeskClock.class, alarmId) .putExtra(AlarmClockFragment.SCROLL_TO_ALARM_INTENT_EXTRA, alarmId) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Open DeskClock which is now positioned on the alarms tab. context.startActivity(viewAlarmIntent); deleteInstanceAndUpdateParent(context, instance); } }
From source file:it.gulch.linuxday.android.services.AlarmIntentService.java
private void updateAlarms(Intent intent) { // Create/update all alarms try {/*from w w w . jav a 2 s . c o m*/ long delay = getDelay(); Date nowDate = new Date(); long now = nowDate.getTime(); List<Bookmark> bookmarks = bookmarkManager.getBookmarks(nowDate); for (Bookmark bookmark : bookmarks) { Event event = bookmark.getEvent(); long notificationTime = event.getStartDate().getTime() - delay; PendingIntent pendingIntent = getAlarmPendingIntent(event.getId()); if (notificationTime < now) { // Cancel pending alarms that where scheduled between now and delay, if any alarmManager.cancel(pendingIntent); } else { alarmManager.set(AlarmManager.RTC_WAKEUP, notificationTime, pendingIntent); } } // Release the wake lock setup by AlarmReceiver, if any if (intent.getBooleanExtra(EXTRA_WITH_WAKE_LOCK, false)) { AlarmReceiver.completeWakefulIntent(intent); } } catch (SQLException e) { Log.e(TAG, e.getMessage(), e); } }
From source file:com.alchemiasoft.book.service.BookActionService.java
@Override protected void onHandleIntent(Intent intent) { final int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, NOT_VALID_NOTIFICATION); // Cancelling any shown notification if (notificationId != NOT_VALID_NOTIFICATION) { Log.d(TAG_LOG, "Dismissing notification with id=" + notificationId); NotificationManagerCompat.from(this).cancel(notificationId); }/* ww w . ja va 2 s.c om*/ final long bookId = intent.getLongExtra(EXTRA_BOOK_ID, NOT_VALID_BOOK); if (bookId != NOT_VALID_BOOK) { final ContentResolver cr = getContentResolver(); final Action action = Action.valueOf(intent.getAction()); Log.d(TAG_LOG, "Performing action=" + action + " on book with id=" + bookId); final ContentValues cv = new ContentValues(); switch (action) { case BUY: cv.put(BookDB.Book.OWNED, 1); if (cr.update(BookDB.Book.create(bookId), cv, null, null) == 1 && intent.getBooleanExtra(EXTRA_WEARABLE_INPUT, false)) { final Book book = getBook(bookId); if (book != null) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true) .setContentTitle(getString(R.string.book_purchased)) .setContentText(book.getTitle()); builder.setContentIntent(PendingIntent.getActivity(this, 0, HomeActivity.createFor(this, book), PendingIntent.FLAG_UPDATE_CURRENT)); // ONLY 4 WEARABLE(s) final NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); wearableExtender .setBackground(BitmapFactory.decodeResource(getResources(), R.drawable.background)); // ACTION TO SELL A BOOK FROM A WEARABLE final PendingIntent sellIntent = PendingIntent.getService( this, 0, BookActionService.IntentBuilder.sell(this, book) .notificationId(NOTIFICATION_ID).wearableInput().build(), PendingIntent.FLAG_UPDATE_CURRENT); wearableExtender.addAction(new NotificationCompat.Action.Builder(R.drawable.ic_action_sell, getString(R.string.action_sell), sellIntent).build()); // Finally extending the notification builder.extend(wearableExtender); NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, builder.build()); } } break; case SELL: cv.put(BookDB.Book.OWNED, 0); if (cr.update(BookDB.Book.create(bookId), cv, null, null) == 1 && intent.getBooleanExtra(EXTRA_WEARABLE_INPUT, false)) { final Book book = getBook(bookId); if (book != null) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true) .setContentTitle(getString(R.string.book_sold)).setContentText(book.getTitle()); builder.setContentIntent(PendingIntent.getActivity(this, 0, HomeActivity.createFor(this, book), PendingIntent.FLAG_UPDATE_CURRENT)); NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, builder.build()); } } break; case ADD_NOTE: final CharSequence notes = getExtraNotes(intent); if (!TextUtils.isEmpty(notes)) { cv.put(BookDB.Book.NOTES, notes.toString()); cr.update(BookDB.Book.create(bookId), cv, null, null); } break; default: break; } } }
From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java
synchronized private void exportData(Intent intent) { // Gets backup folder String backupName = intent.getStringExtra(INTENT_BACKUP_NAME); File backupDir = StorageHelper.getBackupDir(backupName); // Directory clean in case of previously used backup name StorageHelper.delete(this, backupDir.getAbsolutePath()); // Directory is re-created in case of previously used backup name (removed above) backupDir = StorageHelper.getBackupDir(backupName); // Database backup exportDB(backupDir);/* w ww . ja v a2 s .c o m*/ // exportNotes(backupDir); // Attachments backup exportAttachments(backupDir); // Settings if (intent.getBooleanExtra(INTENT_BACKUP_INCLUDE_SETTINGS, true)) { exportSettings(backupDir); } // Notification of operation ended String title = getString(com.dycody.android.idealnote.R.string.data_export_completed); String text = backupDir.getPath(); createNotification(intent, this, title, text, backupDir); }
From source file:com.flowzr.activity.DateFilterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.date_filter); df = DateUtils.getShortDateFormat(this); Intent intent = getIntent(); setCorrectPeriods(intent);/* w w w .j a v a2s . c o m*/ createPeriodsSpinner(); Button bNoFilter = (Button) findViewById(R.id.bNoFilter); bNoFilter.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setResult(RESULT_FIRST_USER); finish(); } }); if (intent == null) { reset(); } else { WhereFilter filter = WhereFilter.fromIntent(intent); DateTimeCriteria c = (DateTimeCriteria) filter.get(BlotterFilter.DATETIME); if (c != null) { if (c.getPeriod() == null || c.getPeriod().type == PeriodType.CUSTOM) { selectPeriod(c.getLongValue1(), c.getLongValue2()); } else { selectPeriod(c.getPeriod()); } } if (intent.getBooleanExtra(EXTRA_FILTER_DONT_SHOW_NO_FILTER, false)) { bNoFilter.setVisibility(View.GONE); } } buttonPeriodFrom = (Button) findViewById(R.id.bPeriodFrom); buttonPeriodFrom.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Calendar c = cFrom; DatePickerDialog d = new DatePickerDialog(DateFilterActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, monthOfYear); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); DateUtils.startOfDay(c); cFrom.setTimeInMillis(c.getTimeInMillis()); updateDate(); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); d.show(); } }); buttonPeriodTo = (Button) findViewById(R.id.bPeriodTo); buttonPeriodTo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Calendar c = cTo; DatePickerDialog d = new DatePickerDialog(DateFilterActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, monthOfYear); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); DateUtils.startOfDay(c); cTo.setTimeInMillis(c.getTimeInMillis()); updateDate(); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); d.show(); } }); }