List of usage examples for android.content Intent getLongArrayExtra
public long[] getLongArrayExtra(String name)
From source file:org.smssecure.smssecure.notifications.WearReplyReceiver.java
@Override protected void onReceive(final Context context, Intent intent, final @Nullable MasterSecret masterSecret) { if (!REPLY_ACTION.equals(intent.getAction())) return;//from w w w . java2s.c o m Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) return; final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA); final CharSequence responseText = remoteInput.getCharSequence(MessageNotifier.EXTRA_VOICE_REPLY); final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false); if (masterSecret != null && responseText != null) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { long threadId; Optional<RecipientsPreferences> preferences = DatabaseFactory .getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds); int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1; if (recipients.isGroupRecipient()) { OutgoingMediaMessage reply = new OutgoingMediaMessage(recipients, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, 0); threadId = MessageSender.send(context, masterSecret, reply, -1, false); } else { OutgoingTextMessage reply = new OutgoingTextMessage(recipients, responseText.toString(), subscriptionId); threadId = MessageSender.send(context, masterSecret, reply, -1, false); } DatabaseFactory.getThreadDatabase(context).setRead(threadId); MessageNotifier.updateNotification(context, masterSecret); return null; } }.execute(); } }
From source file:org.thoughtcrime.securesms.notifications.RemoteReplyReceiver.java
@Override protected void onReceive(final Context context, Intent intent, final @Nullable MasterSecret masterSecret) { if (!REPLY_ACTION.equals(intent.getAction())) return;// w ww. j a v a 2 s . c om Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) return; final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA); final CharSequence responseText = remoteInput.getCharSequence(MessageNotifier.EXTRA_REMOTE_REPLY); if (masterSecret != null && responseText != null) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { long threadId; Optional<RecipientsPreferences> preferences = DatabaseFactory .getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds); int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1; long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0; Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false); if (recipients.isGroupRecipient()) { OutgoingMediaMessage reply = new OutgoingMediaMessage(recipients, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0); threadId = MessageSender.send(context, masterSecret, reply, -1, false); } else { OutgoingTextMessage reply = new OutgoingTextMessage(recipients, responseText.toString(), expiresIn, subscriptionId); threadId = MessageSender.send(context, masterSecret, reply, -1, false); } List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context) .setRead(threadId, true); MessageNotifier.updateNotification(context, masterSecret); MarkReadReceiver.process(context, messageIds); return null; } }.execute(); } }
From source file:org.smssecure.smssecure.notifications.RemoteReplyReceiver.java
@Override protected void onReceive(final Context context, Intent intent, final @Nullable MasterSecret masterSecret) { if (!REPLY_ACTION.equals(intent.getAction())) return;//from w w w .j av a 2 s . c om Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) return; final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA); final CharSequence responseText = remoteInput.getCharSequence(MessageNotifier.EXTRA_REMOTE_REPLY); if (masterSecret != null && responseText != null) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { long threadId; Optional<RecipientsPreferences> preferences = DatabaseFactory .getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds); int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1; Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false); if (recipients.isGroupRecipient()) { OutgoingMediaMessage reply = new OutgoingMediaMessage(recipients, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, 0); threadId = MessageSender.send(context, masterSecret, reply, -1, false); } else { boolean secure = SessionUtil.hasSession(context, masterSecret, recipients.getPrimaryRecipient()); OutgoingTextMessage reply; if (!secure) { reply = new OutgoingTextMessage(recipients, responseText.toString(), subscriptionId); } else { reply = new OutgoingEncryptedMessage(recipients, responseText.toString(), subscriptionId); } threadId = MessageSender.send(context, masterSecret, reply, -1, false); } DatabaseFactory.getThreadDatabase(context).setRead(threadId); DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId); MessageNotifier.updateNotification(context, masterSecret); return null; } }.execute(); } }
From source file:org.thoughtcrime.securesms.notifications.AndroidAutoReplyReceiver.java
@Override protected void onReceive(final Context context, Intent intent, final @Nullable MasterSecret masterSecret) { if (!REPLY_ACTION.equals(intent.getAction())) return;//from www.jav a 2s. c om Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) return; final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA); final long threadId = intent.getLongExtra(THREAD_ID_EXTRA, -1); final CharSequence responseText = getMessageText(intent); final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false); if (responseText != null) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { long replyThreadId; Optional<RecipientsPreferences> preferences = DatabaseFactory .getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds); int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1; long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0; if (recipients.isGroupRecipient()) { Log.i("AndroidAutoReplyReceiver", "GroupRecipient, Sending media message"); OutgoingMediaMessage reply = new OutgoingMediaMessage(recipients, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0); replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false); } else { Log.i("AndroidAutoReplyReceiver", "Sending regular message "); OutgoingTextMessage reply = new OutgoingTextMessage(recipients, responseText.toString(), expiresIn, subscriptionId); replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false); } List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context) .setRead(replyThreadId, true); MessageNotifier.updateNotification(context, masterSecret); MarkReadReceiver.process(context, messageIds); return null; } }.execute(); } }
From source file:nz.ac.otago.psyanlab.common.PaleActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUEST_IMPORT: switch (resultCode) { case RESULT_OK: handleImportedIds(data.getLongArrayExtra(ImportPaleActivity.RETURN_IDS)); break; default:/*from w ww.j av a 2 s. c om*/ break; } break; case REQUEST_NEW: switch (resultCode) { case RESULT_OK: { // Nothing let the list fragment know that we have a new // experiment and to choose it for the user. long experimentId = data.getLongExtra(Args.EXPERIMENT_ID, -1); mPaleListFragment.onExperimentInsert(experimentId); onItemSelected(experimentId); break; } default: { // We have to delete the experiment because it was // discarded by the user. long experimentId = data.getLongExtra(Args.EXPERIMENT_ID, -1); if (experimentId != -1) { try { mUserDelegate.getUserExperimentDelegate(experimentId).deleteExperiment(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } } else { throw new RuntimeException("Invalid experiment id."); } break; } } break; default: break; } }
From source file:mobisocial.musubi.ui.EmailUnclaimedMembersActivity.java
private MIdentity[] markAsHasSent(final Intent mIntent) { SQLiteOpenHelper dbhelper = App.getDatabaseSource(EmailUnclaimedMembersActivity.this); IdentitiesManager manager = new IdentitiesManager(dbhelper); long ids[] = mIntent.getLongArrayExtra(INTENT_EXTRA_RECIPIENT_IDS); MIdentity identities[] = manager.getIdentitiesForIds(ids); for (int i = 0; i < identities.length; i++) { identities[i].hasSentEmail_ = true; manager.updateIdentity(identities[i]); }/*from w ww. j a va 2 s . co m*/ return identities; }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedMembersFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_INVITE_TO_GROUP) { if (resultCode == Activity.RESULT_OK) { long[] contactIds = data.getLongArrayExtra("contacts"); try { Helpers.sendGroupInvite(getActivity(), contactIds, mGroup.get()); } catch (Maybe.NoValError e) { }// w ww.ja v a 2 s. c om } } }
From source file:com.android.calendarDemo.alerts.DismissAlarmsService.java
@Override public void onHandleIntent(Intent intent) { long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1); long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1); long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1); boolean showEvent = intent.getBooleanExtra(AlertUtils.SHOW_EVENT_KEY, false); long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY); int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1); Uri uri = CalendarAlerts.CONTENT_URI; String selection;//from w w w . ja va 2s . c om // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms if (eventId != -1) { selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID + "=" + eventId; } else if (eventIds != null && eventIds.length > 0) { selection = buildMultipleEventsQuery(eventIds); } else { selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED; } ContentResolver resolver = getContentResolver(); ContentValues values = new ContentValues(); values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED); resolver.update(uri, values, selection, null); // Remove from notification bar. if (notificationId != -1) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); } if (showEvent) { // Show event on Calendar app by building an intent and task stack to start // EventInfoActivity with AllInOneActivity as the parent activity rooted to home. Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd); TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i) .startActivities(); } // Stop this service stopSelf(); }
From source file:com.android.calendar.alerts.DismissAlarmsService.java
@Override public void onHandleIntent(Intent intent) { long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1); long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1); long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1); boolean showEvent = intent.getBooleanExtra(AlertUtils.SHOW_EVENT_KEY, false); long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY); long[] eventStarts = intent.getLongArrayExtra(AlertUtils.EVENT_STARTS_KEY); int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1); List<AlarmId> alarmIds = new LinkedList<AlarmId>(); Uri uri = CalendarAlerts.CONTENT_URI; String selection;/*from w ww . j ava2 s .com*/ // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms if (eventId != -1) { alarmIds.add(new AlarmId(eventId, eventStart)); selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID + "=" + eventId; } else if (eventIds != null && eventIds.length > 0 && eventStarts != null && eventIds.length == eventStarts.length) { selection = buildMultipleEventsQuery(eventIds); for (int i = 0; i < eventIds.length; i++) { alarmIds.add(new AlarmId(eventIds[i], eventStarts[i])); } } else { // NOTE: I don't believe that this ever happens. selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED; } GlobalDismissManager.dismissGlobally(getApplicationContext(), alarmIds); ContentResolver resolver = getContentResolver(); ContentValues values = new ContentValues(); values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED); resolver.update(uri, values, selection, null); // Remove from notification bar. if (notificationId != -1) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); } if (showEvent) { // Show event on Calendar app by building an intent and task stack to start // EventInfoActivity with AllInOneActivity as the parent activity rooted to home. Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd); TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i) .startActivities(); } }
From source file:edu.stanford.mobisocial.dungbeetle.GroupsActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_INVITE_TO_GROUP) { if (resultCode == RESULT_OK) { long[] contactIds = data.getLongArrayExtra("contacts"); try { Helpers.sendGroupInvite(this, contactIds, mGroup.get()); } catch (Maybe.NoValError e) { }/*from w w w .j a va 2s . c o m*/ } } mGroup = Maybe.unknown(); }