List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:com.javielinux.tweettopics2.UserActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == UserActivity.ACTIVITY_INCLUDE_IN_LIST) { if (data != null && data.getExtras().containsKey(UserListsSelectorActivity.KEY_ACTIVE_USER_ID) && data.getExtras().containsKey(UserListsSelectorActivity.KEY_LIST_ID)) { UserActions.execByCode(UserActions.USER_ACTION_INCLUDED_LIST, UserActivity.this, data.getLongExtra(UserListsSelectorActivity.KEY_ACTIVE_USER_ID, -1), infoUser, data.getIntExtra(UserListsSelectorActivity.KEY_LIST_ID, -1)); }/* www . ja v a 2 s. co m*/ } }
From source file:com.luboganev.dejalist.ui.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_NEW_PRODUCT || requestCode == REQUEST_CODE_EDIT_PRODUCT) { if (resultCode == Activity.RESULT_OK) { long productCategoryId = data.getLongExtra(ProductActivity.RESULT_EXTRA_PRODUCT_CATEGORY_ID, Products.PRODUCT_CATEGORY_NONE_ID); int checkedPosition = mDrawerList.getCheckedItemPosition(); if (checkedPosition != NavigationCursorAdapter.POSITION_ALL_PRODUCTS && mAdapter.getItemId(checkedPosition) != productCategoryId) { final int count = mAdapter.getCount() - 1; // we do not want the add categories button, only the categories // we start from 2 because position 0 is Checklist and position 1 is All products, // which are both not related to categories at all int pos = 0; while (pos < count) { if (productCategoryId == mAdapter.getItemId(pos)) { selectItem(pos); break; }/* w ww . j a v a 2 s.co m*/ pos++; } // Unfortunately cannot switch to a newly inserted category // because of the loaders. A solution needs to // be found in a future release. if (pos == count) selectItem(NavigationCursorAdapter.POSITION_ALL_PRODUCTS); } else { if (mProductsGalleryActionTaker != null) mProductsGalleryActionTaker.reloadProducts(); } } } }
From source file:org.getlantern.firetweet.service.BackgroundOperationService.java
private void handleSendDirectMessageIntent(final Intent intent) { final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1); final long recipientId = intent.getLongExtra(EXTRA_RECIPIENT_ID, -1); final String imageUri = intent.getStringExtra(EXTRA_IMAGE_URI); final String text = intent.getStringExtra(EXTRA_TEXT); if (accountId <= 0 || recipientId <= 0 || isEmpty(text)) return;/*from ww w . j av a 2s . c o m*/ final String title = getString(R.string.sending_direct_message); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.ic_stat_send); builder.setProgress(100, 0, true); builder.setTicker(title); builder.setContentTitle(title); builder.setContentText(text); builder.setOngoing(true); final Notification notification = builder.build(); startForeground(NOTIFICATION_ID_SEND_DIRECT_MESSAGE, notification); final SingleResponse<ParcelableDirectMessage> result = sendDirectMessage(builder, accountId, recipientId, text, imageUri); if (result.getData() != null && result.getData().id > 0) { final ContentValues values = ContentValuesCreator.createDirectMessage(result.getData()); final String delete_where = DirectMessages.ACCOUNT_ID + " = " + accountId + " AND " + DirectMessages.MESSAGE_ID + " = " + result.getData().id; mResolver.delete(DirectMessages.Outbox.CONTENT_URI, delete_where, null); mResolver.insert(DirectMessages.Outbox.CONTENT_URI, values); showOkMessage(R.string.direct_message_sent, false); } else { final ContentValues values = createMessageDraft(accountId, recipientId, text, imageUri); mResolver.insert(Drafts.CONTENT_URI, values); showErrorMessage(R.string.action_sending_direct_message, result.getException(), true); } stopForeground(false); mNotificationManager.cancel(NOTIFICATION_ID_SEND_DIRECT_MESSAGE); }
From source file:com.google.android.apps.mytracks.TrackDetailActivity.java
/** * Handles the data in the intent./*from w w w . java2 s.c om*/ */ private void handleIntent(Intent intent) { trackId = intent.getLongExtra(EXTRA_TRACK_ID, -1L); markerId = intent.getLongExtra(EXTRA_MARKER_ID, -1L); if (markerId != -1L) { Waypoint waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(markerId); if (waypoint == null) { exit(); return; } trackId = waypoint.getTrackId(); } if (trackId == -1L) { exit(); return; } }
From source file:net.olejon.mdapp.MedicationActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Intent/*from w w w .j a v a2s . c o m*/ final Intent intent = getIntent(); medicationId = intent.getLongExtra("id", 0); if (medicationId == 0) { mTools.showToast(getString(R.string.medication_could_not_find_medication), 1); finish(); return; } // Input manager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Layout setContentView(R.layout.activity_medication); // View mRelativeLayout = (RelativeLayout) findViewById(R.id.medication_inner_layout); // Toolbar mToolbar = (Toolbar) findViewById(R.id.medication_toolbar); mToolbar.setTitle(""); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbarSearchLayout = (LinearLayout) findViewById(R.id.medication_toolbar_search_layout); mToolbarSearchEditText = (EditText) findViewById(R.id.medication_toolbar_search); // View pager mViewPager = (ViewPager) findViewById(R.id.medication_pager); // Find in text mToolbarSearchEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { String find = mToolbarSearchEditText.getText().toString().trim(); if (find.equals("")) { if (mWebView != null) mWebView.clearMatches(); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (mWebView != null) mWebView.findAllAsync(find); } else { if (mWebView != null) { //noinspection deprecation mWebView.findAll(find); } } } } @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { } }); mToolbarSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_SEARCH || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) { mInputMethodManager.hideSoftInputFromWindow(mToolbarSearchEditText.getWindowToken(), 0); return true; } return false; } }); }
From source file:org.mariotaku.twidere.activity.support.QuickSearchBarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quick_search_bar); final List<ParcelableCredentials> accounts = ParcelableAccount.getCredentialsList(this, false); final AccountsSpinnerAdapter accountsSpinnerAdapter = new AccountsSpinnerAdapter(this, R.layout.spinner_item_account_icon); accountsSpinnerAdapter.setDropDownViewResource(R.layout.list_item_user); accountsSpinnerAdapter.addAll(accounts); mAccountSpinner.setAdapter(accountsSpinnerAdapter); mAccountSpinner.setOnItemSelectedListener(this); if (savedInstanceState == null) { final Intent intent = getIntent(); final int index = accountsSpinnerAdapter.findItemPosition(intent.getLongExtra(EXTRA_ACCOUNT_ID, -1)); if (index != -1) { mAccountSpinner.setSelection(index); }//from ww w .ja v a 2s. c om } mMainContent.setOnFitSystemWindowsListener(this); mUsersSearchAdapter = new SuggestionsAdapter(this); mSuggestionsList.setAdapter(mUsersSearchAdapter); mSuggestionsList.setOnItemClickListener(this); final SwipeDismissListViewTouchListener listener = new SwipeDismissListViewTouchListener(mSuggestionsList, this); mSuggestionsList.setOnTouchListener(listener); mSuggestionsList.setOnScrollListener(listener.makeScrollListener()); mSearchSubmit.setOnClickListener(this); EditTextEnterHandler.attach(mSearchQuery, new EnterListener() { @Override public void onHitEnter() { doSearch(); } }, true); mSearchQuery.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { mTextChanged = true; } @Override public void afterTextChanged(Editable s) { if (Utils.removeLineBreaks(s)) { doSearch(); } else { getSupportLoaderManager().restartLoader(0, null, QuickSearchBarActivity.this); } } }); getSupportLoaderManager().initLoader(0, null, this); }
From source file:com.jesusla.google.BillingReceiver.java
/** * This is the entry point for all asynchronous messages sent from Android Market to * the application. This method forwards the messages on to the * {@link BillingService}, which handles the communication back to Android Market. * The {@link BillingService} also reports state changes back to the application through * the {@link ResponseHandler}.//from www.ja v a 2s.co m */ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) { String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA); String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE); purchaseStateChanged(context, signedData, signature); } else if (Consts.ACTION_NOTIFY.equals(action)) { String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID); if (Consts.DEBUG) { Log.i(TAG, "notifyId: " + notifyId); } notify(context, notifyId); } 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()); checkResponseCode(context, requestId, responseCodeIndex); } else { Log.w(TAG, "unexpected action: " + action); } }
From source file:com.linkbubble.MainService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { String cmd = intent != null ? intent.getStringExtra("cmd") : null; CrashTracking.log("MainService.onStartCommand(), cmd:" + cmd); MainController mainController = MainController.get(); if (mainController == null || intent == null || cmd == null) { stopSelf();/*from w ww .j a va 2 s . co m*/ return START_NOT_STICKY; } long urlLoadStartTime = intent.getLongExtra("start_time", System.currentTimeMillis()); if (cmd.compareTo("open") == 0) { String url = intent.getStringExtra("url"); if (url != null) { String openedFromAppName = intent.getStringExtra("openedFromAppName"); mainController.openUrl(url, urlLoadStartTime, true, openedFromAppName); } } else if (cmd.compareTo("restore") == 0) { if (!mRestoreComplete) { String[] urls = intent.getStringArrayExtra("urls"); if (urls != null) { int startOpenTabCount = mainController.getActiveTabCount(); for (int i = 0; i < urls.length; i++) { String urlAsString = urls[i]; if (urlAsString != null && !urlAsString.equals(Constant.WELCOME_MESSAGE_URL)) { boolean setAsCurrentTab = false; if (startOpenTabCount == 0) { setAsCurrentTab = i == urls.length - 1; } mainController.openUrl(urlAsString, urlLoadStartTime, setAsCurrentTab, Analytics.OPENED_URL_FROM_RESTORE); } } } mRestoreComplete = true; } } return START_STICKY; }
From source file:de.vanita5.twittnuker.service.BackgroundOperationService.java
private void handleSendDirectMessageIntent(final Intent intent) { final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1); final long recipientId = intent.getLongExtra(EXTRA_RECIPIENT_ID, -1); final String imageUri = intent.getStringExtra(EXTRA_IMAGE_URI); final String text = intent.getStringExtra(EXTRA_TEXT); if (accountId <= 0 || recipientId <= 0 || isEmpty(text)) return;//from ww w . j a va2 s.com final String title = getString(R.string.sending_direct_message); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.ic_stat_send); builder.setProgress(100, 0, true); builder.setTicker(title); builder.setContentTitle(title); builder.setContentText(text); builder.setOngoing(true); final Notification notification = builder.build(); startForeground(NOTIFICATION_ID_SEND_DIRECT_MESSAGE, notification); final SingleResponse<ParcelableDirectMessage> result = sendDirectMessage(builder, accountId, recipientId, text, imageUri); if (result.getData() != null && result.getData().id > 0) { final ContentValues values = makeDirectMessageContentValues(result.getData()); final String delete_where = DirectMessages.ACCOUNT_ID + " = " + accountId + " AND " + DirectMessages.MESSAGE_ID + " = " + result.getData().id; mResolver.delete(DirectMessages.Outbox.CONTENT_URI, delete_where, null); mResolver.insert(DirectMessages.Outbox.CONTENT_URI, values); showOkMessage(R.string.direct_message_sent, false); } else { final ContentValues values = makeDirectMessageDraftContentValues(accountId, recipientId, text, imageUri); mResolver.insert(Drafts.CONTENT_URI, values); showErrorMessage(R.string.action_sending_direct_message, result.getException(), true); } stopForeground(false); mNotificationManager.cancel(NOTIFICATION_ID_SEND_DIRECT_MESSAGE); }
From source file:org.strongswan.android.ui.VpnProfileControlActivity.java
/** * Start the VPN profile referred to by the given intent. Displays an error * if the profile doesn't exist./*from w w w . ja v a 2 s. c o m*/ * * @param intent Intent that caused us to start this */ private void startVpnProfile(Intent intent) { VpnProfile profile = null; VpnProfileDataSource dataSource = new VpnProfileDataSource(this); dataSource.open(); String profileUUID = intent.getStringExtra(EXTRA_VPN_PROFILE_ID); if (profileUUID != null) { profile = dataSource.getVpnProfile(profileUUID); } else { long profileId = intent.getLongExtra(EXTRA_VPN_PROFILE_ID, 0); if (profileId > 0) { profile = dataSource.getVpnProfile(profileId); } } dataSource.close(); if (profile != null) { startVpnProfile(profile); } else { Toast.makeText(this, R.string.profile_not_found, Toast.LENGTH_LONG).show(); finish(); } }