List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:eu.power_switch.gui.fragment.configure_timer.ConfigureTimerDialogPage4TabbedSummaryFragment.java
@Nullable @Override//from w w w . j ava2s. c o m public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.dialog_fragment_configure_timer_page_4_summary, container, false); // BroadcastReceiver to get notifications from background service if room data has changed broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (LocalBroadcastConstants.INTENT_TIMER_NAME_EXECUTION_TIME_CHANGED.equals(intent.getAction())) { currentExecutionTime = (Calendar) intent.getSerializableExtra("executionTime"); currentName = intent.getStringExtra("name"); } else if (LocalBroadcastConstants.INTENT_TIMER_EXECUTION_INTERVAL_CHANGED .equals(intent.getAction())) { currentExecutionInterval = intent.getLongExtra("executionInterval", -1); currentExecutionDays = (ArrayList<WeekdayTimer.Day>) intent .getSerializableExtra("executionDays"); currentExecutionType = intent.getStringExtra("executionType"); } else if (LocalBroadcastConstants.INTENT_TIMER_ACTIONS_CHANGED.equals(intent.getAction())) { currentActions = (ArrayList<Action>) intent.getSerializableExtra("actions"); } updateUi(); notifyConfigurationChanged(); } }; textViewName = (TextView) rootView.findViewById(R.id.textView_name); textViewTime = (TextView) rootView.findViewById(R.id.textView_time); textViewDays = (TextView) rootView.findViewById(R.id.textView_execution_days); textViewAction = (TextView) rootView.findViewById(R.id.textView_action); Bundle args = getArguments(); if (args != null && args.containsKey(ConfigureTimerDialog.TIMER_ID_KEY)) { currentId = args.getLong(ConfigureTimerDialog.TIMER_ID_KEY); initializeTimerData(currentId); } checkSetupValidity(); updateUi(); return rootView; }
From source file:com.android.calendar.event.EditEventActivity.java
private EventInfo getEventInfoFromIntent(Bundle icicle) { EventInfo info = new EventInfo(); long eventId = -1; Intent intent = getIntent(); Uri data = intent.getData();//from ww w.jav a 2s. co m if (data != null) { try { eventId = Long.parseLong(data.getLastPathSegment()); } catch (NumberFormatException e) { if (DEBUG) { Log.d(TAG, "Create new event"); } } } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) { eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID); } boolean allDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false); long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1); long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1); if (end != -1) { info.endTime = new Time(); if (allDay) { info.endTime.timezone = Time.TIMEZONE_UTC; } info.endTime.set(end); } if (begin != -1) { info.startTime = new Time(); if (allDay) { info.startTime.timezone = Time.TIMEZONE_UTC; } info.startTime.set(begin); } info.id = eventId; info.eventTitle = intent.getStringExtra(Events.TITLE); info.calendarId = intent.getLongExtra(Events.CALENDAR_ID, -1); if (allDay) { info.extraLong = CalendarController.EXTRA_CREATE_ALL_DAY; } else { info.extraLong = 0; } return info; }
From source file:com.mobicage.rogerthat.NewsActivity.java
private void processIntent(Intent intent, Boolean start) { if (intent != null) { final String url = intent.getDataString(); if (url != null) { processUrl(url);/*from w w w. j a v a2 s . com*/ } if (start) { mIdToShowAtTop = intent.getLongExtra("id", -1); } } }
From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); LayoutInflater inflate = getLayoutInflater(); mContactListView = (ContactListView) inflate.inflate(R.layout.contact_list_view, null); mFilterView = (ContactListFilterView) getLayoutInflater().inflate(R.layout.contact_list_filter_view, null); mFilterView.setActivity(this); mFilterView.getListView().setOnCreateContextMenuListener(this); Intent intent = getIntent(); mAccountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, -1); if (mAccountId == -1) { finish();// w ww. j av a 2s. c o m return; } setupActionBarList(mAccountId); mApp = ImApp.getApplication(this); initAccount(); // Get the intent, verify the action and get the query if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (mIsFiltering) { String filterText = intent.getStringExtra(SearchManager.QUERY); mFilterView.doFilter(filterText); } } }
From source file:com.ichi2.anki.Reviewer.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_STATISTICS || requestCode == REQUEST_BROWSE_CARDS) { // select original deck if the statistics or card browser were opened, // which can change the selected deck if (data != null && data.hasExtra("originalDeck")) { getCol().getDecks().select(data.getLongExtra("originalDeck", 0L)); }//from w w w . j a va 2s . c o m } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.hichinaschool.flashcards.anki.multimediacard.activity.MultimediaCardEditorActivity.java
/** * If a note has been passed, loads it. Otherwise creates a new Note It checks for a noteId, a long value with * EXTRA_NOTE_ID as key. If not 0, edits the note, else creates a new note *//*w w w . j a v a 2s .c o m*/ private void initData() { try { mCol = AnkiDroidApp.getCol(); Intent callerIntent = getIntent(); long cardId = callerIntent.getLongExtra(EXTRA_CARD_ID, 0); if (cardId != 0) { mCard = mCol.getCard(cardId); mCurrentDid = mCard.getDid(); mEditorNote = mCard.note(); mCol.getModels().setCurrent(mEditorNote.model()); mNote = NoteService.createEmptyNote(mEditorNote.model()); NoteService.updateMultimediaNoteFromJsonNote(mEditorNote, mNote); mAddNote = false; } else { mCurrentDid = mCol.getDecks().current().getLong("id"); if (mCol.getDecks().isDyn(mCurrentDid)) { mCurrentDid = 1; } mAddNote = true; JSONObject currentModel = mCol.getModels().current(); mNote = NoteService.createEmptyNote(currentModel); if (mNote == null) { Log.e("Multimedia Editor", "Cannot create a Note"); throw new Exception("Could not create a not"); } mEditorNote = new Note(mCol, currentModel); mEditorNote.model().put("did", mCurrentDid); } // TODO take care of tags @see CardEditor setNote(Note) } catch (Exception e) { Log.e("Multimedia Editor", e.getMessage()); finishCancel(); return; } }
From source file:org.kontalk.service.UploadService.java
@Override protected void onHandleIntent(Intent intent) { // crappy firmware - as per docs, intent can't be null in this case if (intent == null) return;/*from www .jav a2s. co m*/ // check for unknown action if (!ACTION_UPLOAD.equals(intent.getAction())) return; // local file to upload Uri file = intent.getData(); String filename = file.toString(); // message database id long databaseId = intent.getLongExtra(EXTRA_DATABASE_ID, 0); // message id String msgId = intent.getStringExtra(EXTRA_MESSAGE_ID); // url to post to String url = intent.getStringExtra(EXTRA_POST_URL); // url to fetch from (will be requested to the connection if null) String fetchUrl = intent.getStringExtra(EXTRA_GET_URL); // group JID String groupJid = intent.getStringExtra(EXTRA_GROUP); // user(s) to send message to String[] to; if (groupJid != null) { to = intent.getStringArrayExtra(EXTRA_USER); } else { to = new String[] { intent.getStringExtra(EXTRA_USER) }; } // media mime type String mime = intent.getStringExtra(EXTRA_MIME); // preview file path String previewPath = intent.getStringExtra(EXTRA_PREVIEW_PATH); // encryption flag boolean encrypt = intent.getBooleanExtra(EXTRA_ENCRYPT, false); // delete original boolean deleteOriginal = intent.getBooleanExtra(EXTRA_DELETE_ORIGINAL, false); // check if upload has already been queued if (queue.get(filename) != null) return; try { // notify user about upload immediately long length = MediaStorage.getLength(this, file); Log.v(TAG, "file size is " + length + " bytes"); mTotalBytes = length; startForeground(0); mCanceled = false; // TODO used class here should be decided by the caller mConn = new HTPPFileUploadConnection(this, url); mMessageId = databaseId; queue.put(filename, mMessageId); // upload content String mediaUrl = mConn.upload(file, length, mime, encrypt, to, this); if (mediaUrl == null) mediaUrl = fetchUrl; Log.d(TAG, "uploaded with media URL: " + mediaUrl); // update message fetch_url MessagesProvider.uploaded(this, databaseId, mediaUrl); // send message with fetch url to server if (groupJid != null) { MessageCenterService.sendGroupUploadedMedia(this, groupJid, to, mime, file, length, previewPath, mediaUrl, encrypt, databaseId, msgId); } else { MessageCenterService.sendUploadedMedia(this, to[0], mime, file, length, previewPath, mediaUrl, encrypt, databaseId, msgId); } // end operations completed(); } catch (Exception e) { error(url, null, e); } finally { // only file uri are supported for delete if (deleteOriginal && "file".equals(file.getScheme())) new File(file.getPath()).delete(); queue.remove(filename); mMessageId = 0; } }
From source file:co.shunya.gita.player.MusicService.java
void processPlayRequest(Intent intent) { Long _id = intent.getLongExtra(INTENT_ID_EXTRA, -1); // if (_id < 0) { // throw new IllegalArgumentException("You must pass the id and language to the intent"); // }//from ww w . j av a 2 s. c om if (mState == State.Retrieving) { // If we are still retrieving media, just set the flag to start playing when we're // ready if (_id < 0) { throw new IllegalArgumentException("something went wrong intent"); } mWhatToPlayAfterRetrieve = _id; // play a requested song mStartPlayingAfterRetrieve = true; return; } tryToGetAudioFocus(); // actually play the song //TODO set the playing mechanism Log.i(TAG, "Current State of player:" + mState.toString()); if (mState == State.Stopped) { if (_id < 0) { throw new IllegalArgumentException("something went wrong with intent"); } // If we're stopped, just go ahead to the next song and start playing playNextSong(_id); } else if (mState == State.Paused) { // If we're paused, just continue playback and restore the 'foreground service' state. setState(State.Playing); updateUI(); setUpAsForeground(mSongTitle + " (playing)"); configAndStartMediaPlayer(); } // Tell any remote controls that our playback state is 'playing'. if (mRemoteControlClientCompat != null) { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } }
From source file:com.nit.vicky.multimediacard.activity.MultimediaCardEditorActivity.java
/** * If a note has been passed, loads it. Otherwise creates a new Note It checks for a noteId, a long value with * EXTRA_NOTE_ID as key. If not 0, edits the note, else creates a new note *///w w w .j ava2s . c om private void initData() { try { mCol = AnkiDroidApp.getCol(); Intent callerIntent = getIntent(); long cardId = callerIntent.getLongExtra(EXTRA_CARD_ID, 0); if (cardId != 0) { mCard = mCol.getCard(cardId); mCurrentDid = mCard.getDid(); mEditorNote = mCard.note(); mCol.getModels().setCurrent(mEditorNote.model()); mNote = NoteService.createEmptyNote(mEditorNote.model()); NoteService.updateMultimediaNoteFromJsonNote(mEditorNote, mNote); mAddNote = false; } else { mCurrentDid = mCol.getDecks().current().getLong("id"); if (mCol.getDecks().isDyn(mCurrentDid)) { mCurrentDid = 1; } mAddNote = true; JSONObject currentModel = mCol.getModels().current(); mNote = NoteService.createEmptyNote(currentModel); if (mNote == null) { Log.e("Multimedia Editor", "Cannot create a Note"); throw new Exception("Could not create a not"); } mNote.getField(0).setText(""); mEditorNote = new Note(mCol, currentModel); mEditorNote.model().put("did", mCurrentDid); } // TODO take care of tags @see CardEditor setNote(Note) } catch (Exception e) { Log.e("Multimedia Editor", e.getMessage()); finishCancel(); return; } }
From source file:com.tct.mail.NotificationActionIntentService.java
@Override protected void onHandleIntent(final Intent intent) { final Context context = this; final String action = intent.getAction(); // TS: chao.zhang 2015-09-21 EMAIL FEATURE-585337 ADD_S //NOTE: handle the refresh intent. if (ACTION_REFRESH.equals(action)) { boolean cleanStatus = intent.getBooleanExtra(NotificationUtils.EXTRA_NEED_CLEAN_STATUS, false); long boxId = intent.getLongExtra(NotificationUtils.EXTRA_OUTBOX_ID, -1); //after click the action,cancel the notification. int notificationId = intent.getIntExtra(NotificationUtils.EXTRA_FAIL_NOTIFICATION_ID, 0); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(notificationId); if (boxId == -1) { LogUtils.e(LOG_TAG,//from w w w . j a va2 s . c o m "can't find the oubox during handle Intent ACTION_REFRESH in NotificationActionIntentService#onHandleIntent"); return; } Uri refreshUri = intent.getData(); if (cleanStatus && isOutboxNotEmpty(context, boxId)) { // 1.clean failed status cleanFaildMailStatus(context, boxId); // 2.start refresh(sync) the outbox context.getContentResolver().query(refreshUri, null, null, null, null); // 3. show the sending toast // Why add toast to Handler? cause the notificationActionIntentService is // asynchronous,so want show toast, // only must add toast to Main thread. Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), R.string.sending, Toast.LENGTH_SHORT).show(); } }); } return; } // TS: chao.zhang 2015-09-21 EMAIL FEATURE-585337 ADD_E else if (ACTION_CALENDAR_NEVER_ASK_AGAIN.equals(action)) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { mNotificationManager.cancel(NotificationController.EXCHANGE_NEWCALENDAR_NOTIFICATION_ID); } MailPrefs.get(context).setIgnoreExchangeCalendarPermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD return; } else if (ACTION_CONTACTS_NEVER_ASK_AGAIN.equals(action)) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { mNotificationManager.cancel(NotificationController.EXCHANGE_NEWCONTACTS_NOTIFICATION_ID); } MailPrefs.get(context).setIgnoreExchangeContactPermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD return; } else if (ACTION_STORAGE_NEVER_ASK_AGAIN.equals(action)) { //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD_S NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { mNotificationManager.cancel(NotificationController.EXCHANGE_NEWSTORAGE_NOTIFICATION_ID); } MailPrefs.get(context).setIgnoreExchangeStoragePermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD_E } /* * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent * to add some extra data, it must unparcel the NotificationAction object. It throws a * ClassNotFoundException when unparcelling. * To avoid this, do the marshalling ourselves. */ final NotificationAction notificationAction; final byte[] data = intent.getByteArrayExtra(EXTRA_NOTIFICATION_ACTION); if (data != null) { final Parcel in = Parcel.obtain(); in.unmarshall(data, 0, data.length); in.setDataPosition(0); notificationAction = NotificationAction.CREATOR.createFromParcel(in, NotificationAction.class.getClassLoader()); } else { LogUtils.wtf(LOG_TAG, "data was null trying to unparcel the NotificationAction"); return; } final Message message = notificationAction.getMessage(); final ContentResolver contentResolver = getContentResolver(); LogUtils.i(LOG_TAG, "Handling %s", action); logNotificationAction(action, notificationAction); if (notificationAction.getSource() == NotificationAction.SOURCE_REMOTE) { // Skip undo if the action is bridged from remote node. This should be similar to the // logic after the Undo notification expires in a regular flow. LogUtils.d(LOG_TAG, "Canceling %s", notificationAction.getNotificationId()); NotificationManagerCompat.from(context).cancel(notificationAction.getNotificationId()); NotificationActionUtils.processDestructiveAction(this, notificationAction); NotificationActionUtils.resendNotifications(context, notificationAction.getAccount(), notificationAction.getFolder()); return; } if (ACTION_UNDO.equals(action)) { NotificationActionUtils.cancelUndoTimeout(context, notificationAction); NotificationActionUtils.cancelUndoNotification(context, notificationAction); } else if (ACTION_ARCHIVE_REMOVE_LABEL.equals(action) || ACTION_DELETE.equals(action)) { // All we need to do is switch to an Undo notification NotificationActionUtils.createUndoNotification(context, notificationAction); NotificationActionUtils.registerUndoTimeout(context, notificationAction); } else { if (ACTION_UNDO_TIMEOUT.equals(action) || ACTION_DESTRUCT.equals(action)) { // Process the action NotificationActionUtils.cancelUndoTimeout(this, notificationAction); NotificationActionUtils.processUndoNotification(this, notificationAction); } else if (ACTION_MARK_READ.equals(action)) { final Uri uri = message.uri; final ContentValues values = new ContentValues(1); values.put(UIProvider.MessageColumns.READ, 1); contentResolver.update(uri, values, null, null); } NotificationActionUtils.resendNotifications(context, notificationAction.getAccount(), notificationAction.getFolder()); } }