List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.nappking.movietimesup.HomeFragment.java
@Override public void onResume() { super.onResume(); if (application.getCurrentFBUser() != null && !gameLaunchedFromDeepLinking) { // As long as the user is logged in and the game hasn't been launched yet // from deep linking, see if it has been deep linked and launch the game appropriately Uri target = getActivity().getIntent().getData(); if (target != null) { Intent i = new Intent(getActivity(), GameActivity.class); // Target is the deep-link Uri, so skip loading this home screen and load the game // directly with the sending user's picture to smash String graphRequestIDsForSendingUser = target.getQueryParameter("request_ids"); String feedPostIDForSendingUser = target.getQueryParameter("challenge_brag"); if (graphRequestIDsForSendingUser != null) { // Deep linked through a Request and use the latest request (request_id) if multiple requests have been sent String[] graphRequestIDsForSendingUsers = graphRequestIDsForSendingUser.split(","); String graphRequestIDForSendingUser = graphRequestIDsForSendingUsers[graphRequestIDsForSendingUsers.length - 1];//from w w w. j a v a 2s. c o m Bundle bundle = new Bundle(); bundle.putString("request_id", graphRequestIDForSendingUser); i.putExtras(bundle); gameLaunchedFromDeepLinking = true; startActivityForResult(i, 0); // Delete the Request now it has been consumed and processed Request deleteFBRequestRequest = new Request(Session.getActiveSession(), graphRequestIDForSendingUser + "_" + application.getCurrentFBUser().getId(), new Bundle(), HttpMethod.DELETE, new Request.Callback() { @Override public void onCompleted(Response response) { FacebookRequestError error = response.getError(); if (error != null) { Log.e(FriendSmashApplication.TAG, "Deleting consumed Request failed: " + error.getErrorMessage()); } else { Log.i(FriendSmashApplication.TAG, "Consumed Request deleted"); } } }); Request.executeBatchAsync(deleteFBRequestRequest); } else if (feedPostIDForSendingUser != null) { // Deep linked through a feed post, so start the game smashing the user specified by the id attached to the // challenge_brag parameter Bundle bundle = new Bundle(); bundle.putString("user_id", feedPostIDForSendingUser); i.putExtras(bundle); gameLaunchedFromDeepLinking = true; startActivityForResult(i, 0); } } else { // Launched with no deep-link Uri, so just continue as normal and load the home screen } } if (!gameLaunchedFromDeepLinking && gameOverMessageDisplaying) { // The game hasn't just been launched from deep linking and the game over message should still be displaying, so ... // Complete the game over logic completeGameOver(750); } }
From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java
/** * onRestart event handler//from ww w. j av a 2s .c om */ @Override protected void onRestart() { // Print log end process LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END); // Print log move screen LogManagerCommon.i(TAG, String.format(Message.MESSAGE_ACTIVITY_MOVE, Message.SCANNER_ACTIVITY_NAME, Message.UNLOCK_ACTIVITY_NAME)); super.onRestart(); if (timeout < (System.currentTimeMillis() - Constants.TIME_OUT)) { Intent intent = new Intent(this, UnlockScreenActivity.class); HashMap<String, LinkedList<String[]>> hashMapArrBook = new HashMap<>(); hashMapArrBook.put(Constants.COLUMN_INFOR_LIST_SCAN, arrBookInlist); Bundle bundle = new Bundle(); //put flag switch OCR bundle.putString(Constants.FLAG_SWITCH_OCR, flagSwitchOCR); bundle.putString(Constants.COLUMN_USER_ID, userID); bundle.putString(Constants.COLUMN_SHOP_ID, shopID); bundle.putString(Constants.COLUMN_SERVER_NAME, serverName); bundle.putString(Constants.COLUMN_LICENSE, license); bundle.putSerializable(Constants.COLUMN_INFOR_LIST_SCAN, hashMapArrBook); intent.putExtras(bundle); startActivity(intent); finish(); } // Activate HSM license ActivationResult activationResult = ActivationManager.activate(this, license); Toast.makeText(this, "Activation result: " + activationResult, Toast.LENGTH_LONG).show(); // HSM init hsmDecoder = HSMDecoder.getInstance(this); // Declare symbology if (aSwitchOCR.isChecked()) { registerLicenseCommon.EnableOCRDisableJanCode(hsmDecoder); } else { registerLicenseCommon.EnableJanCodeDisableOCR(hsmDecoder); } //Check enable scan if (!isEnableScan) { registerLicenseCommon.DisableScan(hsmDecoder); } // Declare HSM component UI hsmDecoder.enableFlashOnDecode(false); hsmDecoder.enableSound(false); hsmDecoder.enableAimer(false); hsmDecoder.setWindowMode(WindowMode.CENTERING); hsmDecoder.setWindow(18, 42, 0, 100); // Assign listener hsmDecoder.registerPlugin(customPlugin); }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case MENU_HOME: { final String text = mEditText != null ? parseString(mEditText.getText()) : null; if (mContentModified && !isNullOrEmpty(text)) { mUnsavedTweetDialogFragment = (DialogFragment) Fragment.instantiate(this, UnsavedTweetDialogFragment.class.getName()); final Bundle args = new Bundle(); args.putBoolean(INTENT_KEY_IS_NAVIGATE_UP, true); mUnsavedTweetDialogFragment.setArguments(args); mUnsavedTweetDialogFragment.show(getSupportFragmentManager(), "unsaved_tweet"); } else {/*from w w w.j a va2 s. co m*/ NavUtils.navigateUpFromSameTask(this); } break; } case MENU_SEND: { send(); break; } case MENU_SELECT_ACCOUNT: { final Intent intent = new Intent(INTENT_ACTION_SELECT_ACCOUNT); final Bundle bundle = new Bundle(); bundle.putBoolean(INTENT_KEY_ACTIVATED_ONLY, true); bundle.putLongArray(INTENT_KEY_IDS, mAccountIds); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_SELECT_ACCOUNT); break; } } return super.onOptionsItemSelected(item); }
From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { if (mAdapter != null) { getQueryCursor(mAdapter.getQueryHandler(), null); }/*w ww . ja v a 2s .c o m*/ Intent intent = getIntent(); String action = intent != null ? intent.getAction() : null; if (Intent.ACTION_VIEW.equals(action)) { // this is something we got from the search bar Uri uri = intent.getData(); String path = uri.toString(); if (path.startsWith("content://media/external/audio/media/")) { // This is a specific file String id = uri.getLastPathSegment(); long[] list = new long[] { Long.valueOf(id) }; MusicUtils.playAll(this, list, 0); finish(); return; } else if (path.startsWith("content://media/external/audio/albums/")) { // This is an album, show the songs on it Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); i.putExtra("album", uri.getLastPathSegment()); startActivity(i); finish(); return; } else if (path.startsWith("content://media/external/audio/artists/")) { intent = new Intent(Intent.ACTION_VIEW); Bundle bundle = new Bundle(); bundle.putString(MIME_TYPE, Audio.Artists.CONTENT_TYPE); bundle.putString(ARTIST_KEY, uri.getLastPathSegment()); bundle.putLong(BaseColumns._ID, ApolloUtils.getArtistId(uri.getLastPathSegment(), ARTIST_ID, this)); intent.setClass(this, TracksBrowser.class); intent.putExtras(bundle); startActivity(intent); return; } } mFilterString = intent.getStringExtra(SearchManager.QUERY); if (MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { String focus = intent.getStringExtra(MediaStore.EXTRA_MEDIA_FOCUS); String artist = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ARTIST); String album = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ALBUM); String title = intent.getStringExtra(MediaStore.EXTRA_MEDIA_TITLE); if (focus != null) { if (focus.startsWith("audio/") && title != null) { mFilterString = title; } else if (focus.equals(Audio.Albums.ENTRY_CONTENT_TYPE)) { if (album != null) { mFilterString = album; if (artist != null) { mFilterString = mFilterString + " " + artist; } } } else if (focus.equals(Audio.Artists.ENTRY_CONTENT_TYPE)) { if (artist != null) { mFilterString = artist; } } } } setContentView(R.layout.listview); mTrackList = getListView(); mTrackList.setTextFilterEnabled(true); if (mAdapter == null) { mAdapter = new QueryListAdapter(getApplication(), this, R.layout.listview_items, null, // cursor new String[] {}, new int[] {}, 0); setListAdapter(mAdapter); if (TextUtils.isEmpty(mFilterString)) { getQueryCursor(mAdapter.getQueryHandler(), null); } else { mTrackList.setFilterText(mFilterString); mFilterString = null; } } else { mAdapter.setActivity(this); setListAdapter(mAdapter); mQueryCursor = mAdapter.getCursor(); if (mQueryCursor != null) { init(mQueryCursor); } else { getQueryCursor(mAdapter.getQueryHandler(), mFilterString); } } LinearLayout emptyness = (LinearLayout) findViewById(R.id.empty_view); emptyness.setVisibility(View.GONE); }
From source file:com.dwdesign.tweetings.fragment.BaseStatusesListFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { final ParcelableStatus status = mSelectedStatus; if (status == null) return false; final long account_id = getDefaultAccountId(mApplication); switch (item.getItemId()) { case MENU_VIEW: { openStatus(getActivity(), status); break;//from w w w.j av a2 s. c o m } case MENU_SHARE: { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, "@" + status.screen_name + ": " + status.text_plain); startActivity(Intent.createChooser(intent, getString(R.string.share))); break; } case MENU_TRANSLATE: { translate(status); break; } case MENU_RETWEET: { if (isMyRetweet(status)) { mService.destroyStatus(status.account_id, status.status_id); } else { final long id_to_retweet = mSelectedStatus.is_retweet && mSelectedStatus.retweet_id > 0 ? mSelectedStatus.retweet_id : mSelectedStatus.status_id; mService.retweetStatus(status.account_id, id_to_retweet); } break; } case MENU_QUOTE: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id); bundle.putBoolean(INTENT_KEY_IS_QUOTE, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_QUOTE_REPLY: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id); bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, status.status_id); bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, status.screen_name); bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, status.name); bundle.putBoolean(INTENT_KEY_IS_QUOTE, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_ADD_TO_BUFFER: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id); bundle.putBoolean(INTENT_KEY_IS_BUFFER, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_REPLY: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); final List<String> mentions = new Extractor().extractMentionedScreennames(status.text_plain); mentions.remove(status.screen_name); mentions.add(0, status.screen_name); bundle.putStringArray(INTENT_KEY_MENTIONS, mentions.toArray(new String[mentions.size()])); bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id); bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, status.status_id); bundle.putString(INTENT_KEY_IN_REPLY_TO_TWEET, status.text_plain); bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, status.screen_name); bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, status.name); intent.putExtras(bundle); startActivity(intent); break; } case MENU_FAV: { if (mSelectedStatus.is_favorite) { mService.destroyFavorite(status.account_id, status.status_id); } else { mService.createFavorite(status.account_id, status.status_id); } break; } case MENU_CONVERSATION: { openConversation(getActivity(), status.account_id, status.status_id); break; } case MENU_DELETE: { mService.destroyStatus(status.account_id, status.status_id); break; } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_STATUS); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_STATUS, status); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } case MENU_MULTI_SELECT: { if (!mApplication.isMultiSelectActive()) { mApplication.startMultiSelect(); } final NoDuplicatesLinkedList<Object> list = mApplication.getSelectedItems(); if (!list.contains(status)) { list.add(status); } break; } case MENU_BLOCK: { mService.createBlock(account_id, status.user_id); break; } case MENU_REPORT_SPAM: { mService.reportSpam(account_id, status.user_id); break; } case MENU_MUTE_USER: { final String screen_name = status.screen_name; final Uri uri = Filters.Users.CONTENT_URI; final ContentValues values = new ContentValues(); final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).edit(); final ContentResolver resolver = getContentResolver(); values.put(Filters.Users.TEXT, screen_name); resolver.delete(uri, Filters.Users.TEXT + " = '" + screen_name + "'", null); resolver.insert(uri, values); editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit(); Toast.makeText(getActivity(), R.string.user_muted, Toast.LENGTH_SHORT).show(); break; } case MENU_MAKE_GAP: { Uri uri = Statuses.CONTENT_URI; final Uri query_uri = buildQueryUri(uri, false); ContentResolver mResolver = getContentResolver(); final ContentValues values = new ContentValues(); values.put(Statuses.IS_GAP, 1); final StringBuilder where = new StringBuilder(); where.append(Statuses.ACCOUNT_ID + "=" + account_id); where.append(" AND " + Statuses.STATUS_ID + "=" + status.status_id); mResolver.update(query_uri, values, where.toString(), null); getActivity().sendBroadcast(new Intent(BROADCAST_FILTERS_UPDATED).putExtra(INTENT_KEY_SUCCEED, true)); break; } case MENU_COPY: { final CharSequence text = Html.fromHtml(status.text_html); if (ClipboardUtils.setText(getActivity(), text)) { Toast.makeText(getActivity(), R.string.text_copied, Toast.LENGTH_SHORT).show(); } break; } } return true; }
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
private void RunChoice() { storage = CachingStorage.getInstance(); config = storage.loadScheduleConfig(); // if config == null the app is not been activate and // no test can be run if (config == null) { // TODO Add an alert that the app has not been init yet config = new ScheduleConfig(); }/*ww w .jav a2 s .c om*/ testList = config.manual_tests; array_spinner = new String[testList.size() + 1]; array_spinner_int = new int[testList.size() + 1]; Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.choose_test)); // dropdown setup for (int i = 0; i < testList.size(); i++) { TestDescription td = testList.get(i); array_spinner[i] = td.displayName; array_spinner_int[i] = td.testId; } array_spinner[testList.size()] = getString(R.string.all); array_spinner_int[testList.size()] = -1; builder.setItems(array_spinner, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent intent = new Intent(SamKnowsAggregateStatViewerActivity.this, SamKnowsTestViewerActivity.class); Bundle b = new Bundle(); b.putInt("testID", array_spinner_int[which]); intent.putExtras(b); startActivityForResult(intent, 1); overridePendingTransition(R.anim.transition_in, R.anim.transition_out); } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@SuppressWarnings("deprecation") @Override//from w w w. j a va2s . c o m public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case MENU_TAKE_PHOTO: { if (item.getTitle().equals(getString(R.string.remove_photo))) { if (mImageUri == null) return false; removeAttachments(); } else { takePhoto(); } break; } case MENU_LAST_PHOTO: { String[] projection = new String[] { MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA, MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.MIME_TYPE }; final Cursor cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC"); if (cursor.moveToFirst()) { String imageLocation = cursor.getString(1); File imageFile = new File(imageLocation); if (imageFile != null && imageFile.exists()) { // TODO: is there a better way to do this? mImageUri = Uri.fromFile(imageFile); mIsPhotoAttached = false; mIsImageAttached = true; mImageThumbnailPreview.setVisibility(View.VISIBLE); reloadAttachedImageThumbnail(imageFile); } else { mIsImageAttached = false; } setMenu(); boolean isAutoUpload = mPreferences.getBoolean(PREFERENCE_KEY_AUTO_UPLOAD, false); if (!isNullOrEmpty(mUploadProvider) && mIsImageAttached && isAutoUpload) { postMedia(); } } break; } case MENU_ADD_IMAGE: { if (item.getTitle().equals(getString(R.string.remove_image))) { if (mImageUri == null) return false; removeAttachments(); } else { pickImage(); } break; } case MENU_SHORTEN_LINKS: { String s = parseString(mEditText.getText()); new UrlShortenerTask().execute(s); break; } case MENU_ADD_TO_BUFFER: { if (mIsBuffer) { mIsBuffer = false; } else { mIsBuffer = true; } setMenu(); break; } case MENU_SCHEDULE_TWEET: { if (mScheduleDate != null) { mScheduleDate = null; setMenu(); } else { Intent intent = new Intent(INTENT_ACTION_SCHEDULE_TWEET); if (mScheduleDate != null) { Bundle bundle = new Bundle(); bundle.putString(INTENT_KEY_SCHEDULE_DATE_TIME, mScheduleDate); intent.putExtras(bundle); } startActivityForResult(intent, REQUEST_SCHEDULE_DATE); } break; } case MENU_UPLOAD: { if (!isNullOrEmpty(mUploadProvider) && mIsImageAttached) { postMedia(true); } break; } case MENU_ADD_LOCATION: { final boolean attach_location = mPreferences.getBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false); if (!attach_location) { getLocation(); } mPreferences.edit().putBoolean(PREFERENCE_KEY_ATTACH_LOCATION, !attach_location).commit(); setMenu(); break; } case MENU_DRAFTS: { startActivity(new Intent(INTENT_ACTION_DRAFTS)); break; } case MENU_DELETE: { if (mImageUri == null) return false; removeAttachments(); break; } case MENU_EDIT: { if (mImageUri == null) return false; final Intent intent = new Intent(INTENT_ACTION_EXTENSION_EDIT_IMAGE); intent.setData(mImageUri); startActivityForResult(Intent.createChooser(intent, getString(R.string.open_with_extensions)), REQUEST_EDIT_IMAGE); // Create the intent needed to start feather /*Intent newIntent = new Intent( this, FeatherActivity.class ); // set the source image uri newIntent.setData( mImageUri ); // pass the required api key ( http://developers.aviary.com/ ) newIntent.putExtra( "API_KEY", AVIARY_SDK_API_KEY ); // pass the uri of the destination image file (optional) // This will be the same uri you will receive in the onActivityResult //newIntent.putExtra( "output", mImageUri); // format of the destination image (optional) newIntent.putExtra( "output-format", Bitmap.CompressFormat.JPEG.name() ); // output format quality (optional) newIntent.putExtra( "output-quality", 85 ); // you can force feather to display only a certain tools // newIntent.putExtra( "tools-list", new String[]{"ADJUST", "BRIGHTNESS" } ); // enable fast rendering preview newIntent.putExtra( "effect-enable-fast-preview", true ); // limit the image size // You can pass the current display size as max image size because after // the execution of Aviary you can save the HI-RES image so you don't need a big // image for the preview // newIntent.putExtra( "max-image-size", 800 ); // you want to hide the exit alert dialog shown when back is pressed // without saving image first // newIntent.putExtra( "hide-exit-unsave-confirmation", true ); // ..and start feather startActivityForResult( newIntent, ACTION_REQUEST_FEATHER );*/ break; } case MENU_VIEW: { openImage(this, mImageUri, false); break; } case MENU_TOGGLE_SENSITIVE: { final boolean has_media = (mIsImageAttached || mIsPhotoAttached) && mImageUri != null; if (!has_media) return false; mIsPossiblySensitive = !mIsPossiblySensitive; setMenu(); break; } } return true; }
From source file:com.androzic.MapActivity.java
@Override protected void onNewIntent(Intent intent) { Log.e(TAG, "onNewIntent()"); if (intent.hasExtra("launch")) { Serializable object = intent.getExtras().getSerializable("launch"); if (Class.class.isInstance(object)) { Intent launch = new Intent(this, (Class<?>) object); launch.putExtras(intent); launch.removeExtra("launch"); startActivity(launch);/*from w w w .j a v a2 s .c o m*/ } } else if (intent.hasExtra("lat") && intent.hasExtra("lon")) { Androzic application = (Androzic) getApplication(); application.ensureVisible(intent.getExtras().getDouble("lat"), intent.getExtras().getDouble("lon")); } }
From source file:com.efithealth.app.activity.ChatActivity.java
/** * //ww w . j a va 2 s . c o m * * @param view */ public void toGroupDetails(View view) { if (room == null && group == null) { Toast.makeText(getApplicationContext(), R.string.gorup_not_found, 0).show(); return; } if (chatType == CHATTYPE_GROUP) { Intent intent = new Intent(this, GroupDetailsActivity.class); // intent.putExtra("groupId", toChatUsername); Bundle bundle = new Bundle(); bundle.putString("groupId", toChatUsername); bundle.putString("managerid", getIntent().getStringExtra("managerid")); bundle.putString("groupid", getIntent().getStringExtra("groupid")); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_CODE_GROUP_DETAIL); } else { startActivityForResult( (new Intent(this, ChatRoomDetailsActivity.class).putExtra("roomId", toChatUsername)), REQUEST_CODE_GROUP_DETAIL); } }