List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:com.todotxt.todotxttouch.TodoTxtTouch.java
@Override protected void onResume() { super.onResume(); m_app.getStoredSort();/*from w w w.jav a 2 s .c o m*/ m_app.getStoredFilters(); setFilteredTasks(true); // Select the specified item if one was passed in to this activity // e.g. from the widget Intent intent = this.getIntent(); if (intent.hasExtra(Constants.EXTRA_TASK)) { int position = getPositionFromId(intent.getLongExtra(Constants.EXTRA_TASK, 0)); intent.removeExtra(Constants.EXTRA_TASK); getListView().setItemChecked(position, true); } // Show contextactionbar if there is a selection showContextActionBarIfNeeded(); }
From source file:com.nononsenseapps.notepad.ActivityMain.java
/** * Returns a note id from an intent if it contains one, either as part of * its URI or as an extra/*ww w . j ava 2 s .c om*/ * <p/> * Returns -1 if no id was contained, this includes insert actions */ long getNoteId(final Intent intent) { long retval = -1; if (intent != null && intent.getData() != null && (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction()))) { if (intent.getData().getPath().startsWith(TaskList.URI.getPath())) { // Find it in the extras. See DashClock extension for an example retval = intent.getLongExtra(Task.TABLE_NAME, -1); } else if ((intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES) || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES) || intent.getData().getPath().startsWith(Task.URI.getPath()))) { retval = Long.parseLong(intent.getData().getLastPathSegment()); } // else if (null != intent // .getStringExtra(TaskDetailFragment.ARG_ITEM_ID)) { // retval = Long.parseLong(intent // .getStringExtra(TaskDetailFragment.ARG_ITEM_ID)); // } } return retval; }
From source file:jp.co.conit.sss.sp.ex1.billing.BillingService.java
/** * The {@link BillingReceiver} sends messages to this service using intents. * Each intent has an action and some extra arguments specific to that * action.//from www. j ava 2 s .co m * * @param intent the intent containing one of the supported actions * @param startId an identifier for the invocation instance of this service */ public void handleCommand(Intent intent, int startId) { if (intent == null) { return; } String action = intent.getAction(); if (Consts.ACTION_CONFIRM_NOTIFICATION.equals(action)) { String[] notifyIds = intent.getStringArrayExtra(Consts.NOTIFICATION_ID); confirmNotifications(startId, notifyIds); } else if (Consts.ACTION_GET_PURCHASE_INFORMATION.equals(action)) { String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID); getPurchaseInformation(startId, new String[] { notifyId }); } else if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) { String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA); String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE); purchaseStateChanged(startId, signedData, signature); } else if (Consts.ACTION_RESPONSE_CODE.equals(action)) { long requestId = intent.getLongExtra(Consts.INAPP_REQUEST_ID, -1); int responseCodeIndex = intent.getIntExtra(Consts.INAPP_RESPONSE_CODE, ResponseCode.RESULT_ERROR.ordinal()); ResponseCode responseCode = ResponseCode.valueOf(responseCodeIndex); checkResponseCode(requestId, responseCode); } }
From source file:org.ciasaboark.tacere.activity.fragment.EventsFragment.java
@Override public void onAttach(Context ctx) { super.onAttach(context); context = ctx;/*from w ww .j ava 2s . com*/ databaseInterface = DatabaseInterface.getInstance(context); prefs = new Prefs(context); dataSetManager = new DataSetManager(this, context); BroadcastReceiver datasetChangedReceiver = new BroadcastReceiver() { private static final String TAG = "datasetChangedReceiver"; @Override public void onReceive(Context context, Intent intent) { String source = intent.getStringExtra(DataSetManager.SOURCE_KEY); Log.d(TAG, "got a notification from the service on behalf of " + source); Cursor newCursor = databaseInterface.getEventCursor(); Cursor oldCursor = cursorAdapter.getCursor(); //TODO this should properly go from populated listView to an error message, but might //not go from error message back to populated listView if (oldCursor.getCount() == 0 && newCursor.getCount() != 0) { hideError(); drawEventList(); } else if (oldCursor.getCount() != 0 && newCursor.getCount() == 0) { hideEventList(); drawEmptyEventListError(); } //save the old position int index = eventListview.getFirstVisiblePosition(); View v = eventListview.getChildAt(0); int top = (v == null) ? 0 : v.getTop(); cursorAdapter.changeCursor(newCursor); if (newCursor.getCount() != 0) { long rowChanged = intent.getLongExtra(DataSetManager.ROW_CHANGED, -1); if (rowChanged == -1) { //the notification does not specify a row, so update everything just to be sure cursorAdapter.notifyDataSetChanged(); } else { //a specific row has been updated, check that this row is visible, and, if so, //update only that row int start = eventListview.getFirstVisiblePosition(); int curPos = start; int end = eventListview.getLastVisiblePosition(); while (curPos <= end) { if (rowChanged == eventListview.getItemIdAtPosition(curPos)) { View view = eventListview.getChildAt(curPos - start); cursorAdapter.getView(curPos, view, eventListview); break; } curPos++; } } //restore the last position of the list view eventListview.setSelectionFromTop(index, top); //redraw the widgets setupAndDrawActionButtons(); //if this broadcast message came from the anywhere besides the event silencer service //or the database interface then the service needs to be restarted boolean originIsNotService = !TextUtils.equals(EventSilencerService.class.getName(), source); boolean originIsNotInterface = !TextUtils.equals(DatabaseInterface.class.getName(), source); if (originIsNotService && originIsNotInterface) { AlarmManagerWrapper alarmManagerWrapper = new AlarmManagerWrapper(context); alarmManagerWrapper.scheduleImmediateAlarm(RequestTypes.NORMAL); } } } }; // register to receive broadcast messages LocalBroadcastManager.getInstance(context).registerReceiver(datasetChangedReceiver, new IntentFilter(DataSetManager.BROADCAST_MESSAGE_KEY)); BroadcastReceiver quickSilenceReceiver = new BroadcastReceiver() { private static final String TAG = "QuickSilenceReceiver"; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "received quicksilence broadcast notification"); drawActionButton(); } }; LocalBroadcastManager.getInstance(context).registerReceiver(quickSilenceReceiver, new IntentFilter(EventSilencerService.QUICKSILENCE_BROADCAST_KEY)); // display the updates dialog if it hasn't been shown yet Updates updates = new Updates(context, this); updates.showUpdatesDialogIfNeeded(); showFirstRunWizardIfNeeded(); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java
/** * Fires notifications that have elapsed and sets an alarm to be woken at * the next notification./* w w w . jav a 2 s . c o m*/ * <p/> * If the intent action is ACTION_DELETE, will delete the notification with * the indicated ID, and cancel it from any active notifications. */ @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) || Intent.ACTION_RUN.equals(intent.getAction())) { // Can't cancel anything. Just schedule and notify at end } else { // Always cancel cancelNotification(context, intent.getData()); if (Intent.ACTION_DELETE.equals(intent.getAction()) || ACTION_RESCHEDULE.equals(intent.getAction())) { // Just a notification cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .deleteOrReschedule(context, intent.getData()); } else if (ACTION_SNOOZE.equals(intent.getAction())) { // msec/sec * sec/min * 30 long delay30min = 1000 * 60 * 30; final Calendar now = Calendar.getInstance(); cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .setTime(context, intent.getData(), delay30min + now.getTimeInMillis()); } else if (ACTION_COMPLETE.equals(intent.getAction())) { // Complete note Task.setCompletedSynced(context, true, intent.getLongExtra(ARG_TASKID, -1)); // Delete notifications with the same task id cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .removeWithTaskIdsSynced(context, intent.getLongExtra(ARG_TASKID, -1)); } } notifyPast(context, true); scheduleNext(context); }
From source file:com.android.calendar.AllInOneActivity.java
private long parseViewAction(final Intent intent) { long timeMillis = -1; Uri data = intent.getData();// w w w . ja va2 s .co m if (data != null && data.isHierarchical()) { List<String> path = data.getPathSegments(); if (path.size() == 2 && path.get(0).equals("events")) { try { mViewEventId = Long.valueOf(data.getLastPathSegment()); if (mViewEventId != -1) { mIntentEventStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0); mIntentEventEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0); mIntentAttendeeResponse = intent.getIntExtra(ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_NONE); mIntentAllDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false); timeMillis = mIntentEventStartMillis; } } catch (NumberFormatException e) { // Ignore if mViewEventId can't be parsed } } } return timeMillis; }
From source file:com.xandy.calendar.AllInOneActivity.java
private void initFragments(long timeMillis, int viewType, Bundle icicle) { if (DEBUG) {//from w w w .j a v a 2 s .co m Log.d(TAG, "Initializing to " + timeMillis + " for view " + viewType); } // FragmentTransaction ft = getFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (mShowCalendarControls) { Fragment miniMonthFrag = new MonthByWeekFragment(timeMillis, true); ft.replace(R.id.mini_month, miniMonthFrag); mController.registerEventHandler(R.id.mini_month, (EventHandler) miniMonthFrag); Fragment selectCalendarsFrag = new SelectVisibleCalendarsFragment(); ft.replace(R.id.calendar_list, selectCalendarsFrag); mController.registerEventHandler(R.id.calendar_list, (EventHandler) selectCalendarsFrag); } if (!mShowCalendarControls || viewType == ViewType.EDIT) { mMiniMonth.setVisibility(View.GONE); mCalendarsList.setVisibility(View.GONE); } EventInfo info = null; if (viewType == ViewType.EDIT) { mPreviousView = GeneralPreferences.getSharedPreferences(this).getInt(GeneralPreferences.KEY_START_VIEW, GeneralPreferences.DEFAULT_START_VIEW); long eventId = -1; Intent intent = getIntent(); Uri data = intent.getData(); 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); } long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1); long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1); info = new EventInfo(); if (end != -1) { info.endTime = new Time(); info.endTime.set(end); } if (begin != -1) { info.startTime = new Time(); info.startTime.set(begin); } info.id = eventId; // We set the viewtype so if the user presses back when they are // done editing the controller knows we were in the Edit Event // screen. Likewise for eventId mController.setViewType(viewType); mController.setEventId(eventId); } else { mPreviousView = viewType; } setMainPane(ft, R.id.main_pane, viewType, timeMillis, true); ft.commit(); // this needs to be after setMainPane() Time t = new Time(mTimeZone); t.set(timeMillis); if (viewType == ViewType.AGENDA && icicle != null) { mController.sendEvent(this, EventType.GO_TO, t, null, icicle.getLong(BUNDLE_KEY_EVENT_ID, -1), viewType); } else if (viewType != ViewType.EDIT) { mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType); } }
From source file:com.android.contacts.ContactSaveService.java
private void setSuperPrimary(Intent intent) { long dataId = intent.getLongExtra(EXTRA_DATA_ID, -1); if (dataId == -1) { Log.e(TAG, "Invalid arguments for setSuperPrimary request"); return;// ww w. j av a 2 s .com } ContactUpdateUtils.setSuperPrimary(this, dataId); }
From source file:com.mobicage.rogerthat.NewsActivity.java
private void processFriendInfoReceived(Intent intent) { if (expectedEmailHash != null && expectedEmailHash.equals(intent.getStringExtra(ProcessScanActivity.EMAILHASH))) { mProgressDialog.dismiss();//from w w w . jav a2 s. co m if (intent.getBooleanExtra(ProcessScanActivity.SUCCESS, true)) { Intent launchIntent = new Intent(NewsActivity.this, ServiceDetailActivity.class); if (existence == Friend.DELETED || existence == Friend.DELETION_PENDING) { launchIntent.putExtra(ServiceDetailActivity.EXISTENCE, Friend.NOT_FOUND); } else { launchIntent.putExtra(ServiceDetailActivity.EXISTENCE, existence); } GetUserInfoResponseTO item = new GetUserInfoResponseTO(); item.avatar = intent.getStringExtra(ProcessScanActivity.AVATAR); item.avatar_id = -1; item.description = intent.getStringExtra(ProcessScanActivity.DESCRIPTION); item.descriptionBranding = intent.getStringExtra(ProcessScanActivity.DESCRIPTION_BRANDING); item.email = intent.getStringExtra(ProcessScanActivity.EMAIL); item.name = intent.getStringExtra(ProcessScanActivity.NAME); item.qualifiedIdentifier = intent.getStringExtra(ProcessScanActivity.QUALIFIED_IDENTIFIER); item.type = intent.getLongExtra(ProcessScanActivity.TYPE, FriendsPlugin.FRIEND_TYPE_SERVICE); launchIntent.putExtra(ServiceDetailActivity.GET_USER_INFO_RESULT, JSONValue.toJSONString(item.toJSONMap())); startActivity(launchIntent); } else { UIUtils.showErrorDialog(this, intent); } } }
From source file:com.android.contacts.ContactSaveService.java
private void clearPrimary(Intent intent) { long dataId = intent.getLongExtra(EXTRA_DATA_ID, -1); if (dataId == -1) { Log.e(TAG, "Invalid arguments for clearPrimary request"); return;//w w w .ja v a 2 s . c om } // Update the primary values in the data record. ContentValues values = new ContentValues(1); values.put(Data.IS_SUPER_PRIMARY, 0); values.put(Data.IS_PRIMARY, 0); getContentResolver().update(ContentUris.withAppendedId(Data.CONTENT_URI, dataId), values, null, null); }