List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.bonsai.wallet32.PasscodeActivity.java
private void validateComplete(boolean isValid) { if (!isValid) { mLogger.info("passcode invalid"); // Clear the passcode. setPasscode(""); // Clear the string. mState = State.PASSCODE_ENTER; // If we are paused we defer the dialog to when we // are resumed ... ///*from www.j a v a 2s . com*/ if (!mIsPaused) { showPasscodeInvalidDialog(); } else { mLogger.info("deferring passcode invalid dialog"); mPasscodeWasInvalid = true; } return; } // The passcode was valid. mApp.setPasscodeValidTimestamp(); switch (mAction) { case ACTION_LOGIN: // Spin up the WalletService. Intent svcintent = new Intent(this, WalletService.class); Bundle bundle = new Bundle(); bundle.putString("SyncState", "STARTUP"); svcintent.putExtras(bundle); startService(svcintent); mApp.setLoggedIn(); // Off to the main activity. Intent intent = new Intent(this, MainActivity.class); startActivity(intent); // And we're done with this activity. finish(); break; case ACTION_CHANGE: // Now we're ready to create a new passcode. mState = State.PASSCODE_CREATE; TextView msgtv = (TextView) findViewById(R.id.message); msgtv.setText(R.string.passcode_create); setPasscode(""); show_esthack(true); return; case ACTION_VIEWSEED: // Off to view the seed. Intent intent2 = new Intent(this, ViewSeedActivity.class); intent2.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent2); // And we're done with this activity. finish(); break; case ACTION_SHOWPAIRING: // Off to view the pairing code. Intent intent3 = new Intent(this, ShowPairingActivity.class); intent3.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent3); // And we're done with this activity. finish(); break; } }
From source file:com.fbbackup.ImageGridFragment.java
@TargetApi(16) @Override//from w ww . ja v a2 s. c o m public void onItemClick(AdapterView<?> parent, View v, int position, long id) { final Intent i = new Intent(getActivity(), ImageDetailActivity.class); Bundle bundle = new Bundle(); bundle.putStringArray("photo", photoArray); bundle.putInt("albumPosition", position); bundle.putString("albumName", albumName); bundle.putString("userName", name); i.putExtras(bundle); i.putExtra(ImageDetailActivity.EXTRA_IMAGE, (int) id); if (Utils.hasJellyBean()) { // makeThumbnailScaleUpAnimation() looks kind of ugly here as the // loading spinner may // show plus the thumbnail image in GridView is cropped. so using // makeScaleUpAnimation() instead. ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()); getActivity().startActivity(i, options.toBundle()); } else { startActivity(i); } }
From source file:com.android.contacts.activities.ContactSelectionActivity.java
public void startActivityAndForwardResult(final Intent intent) { intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); // Forward extras to the new activity Bundle extras = getIntent().getExtras(); if (extras != null) { intent.putExtras(extras); }/*www. j a v a2s . c o m*/ try { ImplicitIntentsUtil.startActivityInApp(ContactSelectionActivity.this, intent); } catch (ActivityNotFoundException e) { Log.e(TAG, "startActivity() failed: " + e); Toast.makeText(ContactSelectionActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show(); } finish(); }
From source file:com.group7.dragonwars.MapSelectActivity.java
@Override public final void onItemClick(final AdapterView<?> parent, final View v, final int position, final long id) { if (position < mapInfo.size()) { Intent intent = new Intent(this, PlayerSelectActivity.class); Bundle b = new Bundle(); b.putString("mapFileName", mapInfo.get(position).getPath()); b.putString("mapName", mapInfo.get(position).getName()); int numPlayers = mapInfo.get(position).getPlayers(); b.putBooleanArray("isAi", new boolean[numPlayers]); // boolean defaults to false, what could possibly go wrong? b.putInt("numPlayers", numPlayers); /* Make a fake player list for now, again */ String[] playerNames = new String[numPlayers]; for (Integer i = 0; i < numPlayers; ++i) { playerNames[i] = ("Player " + (i + 1)); }// ww w . ja v a 2 s .c om b.putStringArray("playerNames", playerNames); intent.putExtras(b); startActivity(intent); } }
From source file:com.example.carrie.carrie_test1.druginfo.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_druginfo); Bundle bundle = getIntent().getExtras(); my_id = bundle.getString("my_id");//get id my_google_id = bundle.getString("my_google_id");//get google_ id my_mon_id = bundle.getString("my_supervise_id"); m_calid = bundle.getString("m_calid", "not found"); Log.d("qqqqq", m_calid); btmbar = (RelativeLayout) findViewById(R.id.btmbar); if (my_id.equals("0") && my_google_id.equals("0") && my_mon_id.equals("0")) { //??????? btmbar.setVisibility(View.GONE); } else {// w w w .ja va 2 s. co m BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottomNavView_Bar); BottomNavigationViewHelper.disableShiftMode(bottomNavigationView); Menu menu = bottomNavigationView.getMenu(); MenuItem menuItem = menu.getItem(3); menuItem.setChecked(true); bottomNavigationView.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.ic_list: Intent intent0 = new Intent(druginfo.this, Choice.class); Bundle bundle0 = new Bundle(); bundle0.putString("memberid", my_id); bundle0.putString("my_google_id", my_google_id); bundle0.putString("my_supervise_id", my_mon_id); intent0.putExtras(bundle0); // put??? startActivity(intent0); break; case R.id.ic_eye: Intent intent1 = new Intent(druginfo.this, MonitorActivity.class); Bundle bundle1 = new Bundle(); bundle1.putString("my_id", my_id); bundle1.putString("my_google_id", my_google_id); bundle1.putString("my_supervise_id", my_mon_id); intent1.putExtras(bundle1); startActivity(intent1); break; case R.id.ic_home: Intent intent2 = new Intent(druginfo.this, MainActivity.class); Bundle bundle2 = new Bundle(); bundle2.putString("googleid", my_google_id); intent2.putExtras(bundle2); startActivity(intent2); break; case R.id.ic_information: Intent intent3 = new Intent(druginfo.this, druginfo.class); Bundle bundle3 = new Bundle(); bundle3.putString("my_id", my_id); bundle3.putString("my_google_id", my_google_id); bundle3.putString("my_supervise_id", my_mon_id); intent3.putExtras(bundle3); startActivity(intent3); break; case R.id.ic_beacon: Intent intent4 = new Intent(druginfo.this, Beacon.class); Bundle bundle4 = new Bundle(); bundle4.putString("my_id", my_id); bundle4.putString("my_google_id", my_google_id); bundle4.putString("my_supervise_id", my_mon_id); intent4.putExtras(bundle4); startActivity(intent4); break; } return false; } }); } listView = (ListView) findViewById(R.id.listview); editText = (EditText) findViewById(R.id.textsearch); editText.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) { if (!s.toString().equals("")) { //reset listview // recyclerView = (RecyclerView) findViewById(R.id.recycler_view); // data_list = new ArrayList<>(); // load_data_from_server(0); // // gridLayoutManager = new GridLayoutManager(getBaseContext(), 2); // recyclerView.setLayoutManager(gridLayoutManager); // // adapter = new CustomAdapter2(getBaseContext(), data_list); // recyclerView.setAdapter(adapter); // // recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { // @Override // public void onScrolled(RecyclerView recyclerView, int dx, int dy) { // // if (gridLayoutManager.findLastCompletelyVisibleItemPosition() == data_list.size() - 1) { // load_data_from_server(data_list.get(data_list.size() - 1).getId()); // } // // } // }); recyclerView = (RecyclerView) findViewById(R.id.recycler_view); data_list2 = new ArrayList<>(); Log.d("searchtest", "3"); load_data_from_server_search(s.toString()); Log.d("searchtest", "1"); gridLayoutManager = new GridLayoutManager(getBaseContext(), 2); recyclerView.setLayoutManager(gridLayoutManager); Log.d("searchtest", "2"); adapter = new CustomAdapter2(getBaseContext(), data_list2, m_calid); recyclerView.setAdapter(adapter); } else { recyclerView = (RecyclerView) findViewById(R.id.recycler_view); gridLayoutManager = new GridLayoutManager(getBaseContext(), 2); recyclerView.setLayoutManager(gridLayoutManager); adapter = new CustomAdapter2(getBaseContext(), data_list, m_calid); recyclerView.setAdapter(adapter); } } @Override public void afterTextChanged(Editable s) { } }); recyclerView = (RecyclerView) findViewById(R.id.recycler_view); data_list = new ArrayList<>(); load_data_from_server(0); gridLayoutManager = new GridLayoutManager(this, 2); recyclerView.setLayoutManager(gridLayoutManager); adapter = new CustomAdapter2(this, data_list, m_calid); recyclerView.setAdapter(adapter); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { if (gridLayoutManager.findLastCompletelyVisibleItemPosition() == data_list.size() - 1) { load_data_from_server(data_list.get(data_list.size() - 1).getId()); } } }); }
From source file:com.github.barcodeeye.scan.CaptureActivity.java
private void handleDecodeInternally(Result rawResult, Bitmap barcode) { Uri imageUri = null;//from w ww. j a v a 2 s. c om String imageName = IMAGE_PREFIX + System.currentTimeMillis() + ".png"; Log.v(TAG, "Saving image as: " + imageName); try { imageUri = mImageManager.saveImage(imageName, barcode); } catch (IOException e) { Log.e(TAG, "Failed to save image!", e); } ResultProcessor<?> processor = ResultProcessorFactory.makeResultProcessor(this, rawResult, imageUri); if (!validateQRcode(rawResult.toString())) { Toast.makeText(getApplicationContext(), "Invalid QR code!", Toast.LENGTH_SHORT).show(); onResume(); } else { File f = new File(getCacheDir(), "LoginData.txt"); FileOutputStream fos = null; try { if (!f.exists()) { f.createNewFile(); } fos = new FileOutputStream(f, false); fos.write(rawResult.toString().getBytes()); fos.close(); } catch (IOException e) { Log.e(TAG, "Failed to save Login!", e); } // Intent Creation and Initialization Intent intent = new Intent(context2, InformationPreviewActivity.class); //I have added the line: (flags) (for closing the first activity) intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Create a Bundle and Put Bundle into it (SENDS PERSON) Bundle bundleObject = new Bundle(); bundleObject.putSerializable("key", rawResult.toString()); // Put Bundle into Intent and call start Activity intent.putExtras(bundleObject); startActivity(intent); //I have added the line: (finish) (for closing the first activity) finish(); } // startActivity(ResultsActivity.newIntent(this,processor.getCardResults())); }
From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { // Dialog doesn't allow us to wait for a result, so we need to store // the info we need for when the dialog posts its result mQueryCursor.moveToPosition(position); if (mQueryCursor.isBeforeFirst() || mQueryCursor.isAfterLast()) { return;// w w w . j a va2s.c o m } String selectedType = mQueryCursor.getString(mQueryCursor.getColumnIndexOrThrow(Audio.Media.MIME_TYPE)); if ("artist".equals(selectedType)) { Intent intent = new Intent(Intent.ACTION_VIEW); TextView tv1 = (TextView) v.findViewById(R.id.listview_item_line_one); String artistName = tv1.getText().toString(); Bundle bundle = new Bundle(); bundle.putString(MIME_TYPE, Audio.Artists.CONTENT_TYPE); bundle.putString(ARTIST_KEY, artistName); bundle.putLong(BaseColumns._ID, id); intent.setClass(this, TracksBrowser.class); intent.putExtras(bundle); startActivity(intent); finish(); } else if ("album".equals(selectedType)) { TextView tv1 = (TextView) v.findViewById(R.id.listview_item_line_one); TextView tv2 = (TextView) v.findViewById(R.id.listview_item_line_two); String artistName = tv2.getText().toString(); String albumName = tv1.getText().toString(); Bundle bundle = new Bundle(); bundle.putString(MIME_TYPE, Audio.Albums.CONTENT_TYPE); bundle.putString(ARTIST_KEY, artistName); bundle.putString(ALBUM_KEY, albumName); bundle.putLong(BaseColumns._ID, id); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TracksBrowser.class); intent.putExtras(bundle); startActivity(intent); finish(); } else if (position >= 0 && id >= 0) { long[] list = new long[] { id }; MusicUtils.playAll(this, list, 0); } else { Log.e("QueryBrowser", "invalid position/id: " + position + "/" + id); } }
From source file:com.yairkukielka.feedhungry.EntryListFragment.java
private void refreshItems() { if (streamId == null || accessToken == null || isMix == null || getActivity() == null) { Log.e(TAG, "No stream to load in EntryListFragment.refreshItems or activity is null"); return;/* ww w . java 2 s . c o m*/ } mEntries.clear(); mHasData = false; mAdapter = new ListViewEntryArrayAdapter(getActivity(), 0, mEntries, MyVolley.getImageLoader()); ((AdapterView) mLvPicasa).setAdapter(mAdapter); mLvPicasa.setOnScrollListener(new EndlessScrollListener()); if (!mHasData) { addLoadingFragment(); } mLvPicasa.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(EntryListFragment.this.getActivity(), FeedEntryActivity_.class); ListEntry listEntry = mEntries.get(position); mAdapter.markEntry(MARK_ACTION.READ, mEntries.get(position)); Bundle b = new Bundle(); b.putString(ACCESS_TOKEN, accessToken); b.putString(ENTRY_ID, listEntry.getId()); b.putString(STREAM_ID, streamId); b.putInt(ENTRY_POSITION_IN_STREAM, position); intent.putExtras(b); startActivity(intent); EntryListFragment.this.getActivity().overridePendingTransition(R.anim.open_next, R.anim.close_main); } }); if (!mHasData) { loadPage(false); } }
From source file:com.battlelancer.seriesguide.ui.EpisodeDetailsFragment.java
private void populateEpisodeData(Cursor cursor) { if (cursor == null || !cursor.moveToFirst()) { // no data to display if (mEpisodeContainer != null) { mEpisodeContainer.setVisibility(View.GONE); }/*from w ww . j a va 2 s.c o m*/ return; } mShowTvdbId = cursor.getInt(DetailsQuery.REF_SHOW_ID); mSeasonNumber = cursor.getInt(DetailsQuery.SEASON); mEpisodeNumber = cursor.getInt(DetailsQuery.NUMBER); mShowRunTime = cursor.getInt(DetailsQuery.SHOW_RUNTIME); mEpisodeReleaseTime = cursor.getLong(DetailsQuery.FIRST_RELEASE_MS); // title and description mEpisodeTitle = cursor.getString(DetailsQuery.TITLE); mTitle.setText(mEpisodeTitle); mDescription.setText(cursor.getString(DetailsQuery.OVERVIEW)); // show title mShowTitle = cursor.getString(DetailsQuery.SHOW_TITLE); // release time and day SpannableStringBuilder timeAndNumbersText = new SpannableStringBuilder(); if (mEpisodeReleaseTime != -1) { Date actualRelease = TimeTools.getEpisodeReleaseTime(getActivity(), mEpisodeReleaseTime); mReleaseDay.setText(TimeTools.formatToDate(getActivity(), actualRelease)); // "in 15 mins (Fri)" timeAndNumbersText.append(getString(R.string.release_date_and_day, TimeTools.formatToRelativeLocalReleaseTime(getActivity(), actualRelease), TimeTools.formatToLocalReleaseDay(actualRelease)).toUpperCase(Locale.getDefault())); timeAndNumbersText.append(" "); } else { mReleaseDay.setText(R.string.unknown); } // absolute number (e.g. relevant for Anime): "ABSOLUTE 142" int numberStartIndex = timeAndNumbersText.length(); int absoluteNumber = cursor.getInt(DetailsQuery.ABSOLUTE_NUMBER); if (absoluteNumber > 0) { timeAndNumbersText.append(getString(R.string.episode_number_absolute)).append(" ") .append(String.valueOf(absoluteNumber)); // de-emphasize number timeAndNumbersText.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_Caption_Dim), numberStartIndex, timeAndNumbersText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } mReleaseTime.setText(timeAndNumbersText); // guest stars Utils.setLabelValueOrHide(mLabelGuestStars, mGuestStars, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.GUESTSTARS))); // DVD episode number Utils.setLabelValueOrHide(mLabelDvd, mDvd, cursor.getDouble(DetailsQuery.DVDNUMBER)); // directors Utils.setValueOrPlaceholder(mDirectors, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.DIRECTORS))); // writers Utils.setValueOrPlaceholder(mWriters, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.WRITERS))); // last TVDb edit date long lastEditSeconds = cursor.getLong(DetailsQuery.LASTEDIT); if (lastEditSeconds > 0) { mLastEdit.setText(DateUtils.formatDateTime(getActivity(), lastEditSeconds * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME)); } else { mLastEdit.setText(R.string.unknown); } // ratings mRatingsContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { rateOnTrakt(); } }); mRatingsContainer.setFocusable(true); CheatSheet.setup(mRatingsContainer, R.string.action_rate); // TVDb rating String tvdbRating = cursor.getString(DetailsQuery.RATING); if (!TextUtils.isEmpty(tvdbRating)) { mTvdbRating.setText(tvdbRating); } // trakt ratings loadTraktRatings(true); // episode image final String imagePath = cursor.getString(DetailsQuery.IMAGE); mImageContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent fullscreen = new Intent(getActivity(), FullscreenImageActivity.class); fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_PATH, imagePath); ActivityCompat.startActivity(getActivity(), fullscreen, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); } }); loadImage(imagePath); // check in button final int episodeTvdbId = cursor.getInt(DetailsQuery._ID); mCheckinButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // display a check-in dialog CheckInDialogFragment f = CheckInDialogFragment.newInstance(getActivity(), episodeTvdbId); f.show(getFragmentManager(), "checkin-dialog"); fireTrackerEvent("Check-In"); } }); CheatSheet.setup(mCheckinButton); // watched button mEpisodeFlag = cursor.getInt(DetailsQuery.WATCHED); boolean isWatched = EpisodeTools.isWatched(mEpisodeFlag); Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mWatchedButton, 0, isWatched ? Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatched) : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatch), 0, 0); mWatchedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleWatched(); fireTrackerEvent("Toggle watched"); } }); mWatchedButton.setEnabled(true); mWatchedButton.setText(isWatched ? R.string.action_unwatched : R.string.action_watched); CheatSheet.setup(mWatchedButton, isWatched ? R.string.action_unwatched : R.string.action_watched); // collected button mCollected = cursor.getInt(DetailsQuery.COLLECTED) == 1; Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mCollectedButton, 0, mCollected ? R.drawable.ic_collected : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableCollect), 0, 0); mCollectedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleCollected(); fireTrackerEvent("Toggle collected"); } }); mCollectedButton.setEnabled(true); mCollectedButton.setText(mCollected ? R.string.action_collection_remove : R.string.action_collection_add); CheatSheet.setup(mCollectedButton, mCollected ? R.string.action_collection_remove : R.string.action_collection_add); // skip button boolean isSkipped = EpisodeTools.isSkipped(mEpisodeFlag); if (isWatched) { // if watched do not allow skipping mSkipButton.setVisibility(View.INVISIBLE); } else { mSkipButton.setVisibility(View.VISIBLE); Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mSkipButton, 0, isSkipped ? R.drawable.ic_skipped : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableSkip), 0, 0); mSkipButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleSkipped(); fireTrackerEvent("Toggle skipped"); } }); mSkipButton.setText(isSkipped ? R.string.action_dont_skip : R.string.action_skip); CheatSheet.setup(mSkipButton, isSkipped ? R.string.action_dont_skip : R.string.action_skip); } mSkipButton.setEnabled(true); // service buttons ServiceUtils.setUpTraktButton(mShowTvdbId, mSeasonNumber, mEpisodeNumber, mTraktButton, TAG); // IMDb String imdbId = cursor.getString(DetailsQuery.IMDBID); if (TextUtils.isEmpty(imdbId)) { // fall back to show IMDb id imdbId = cursor.getString(DetailsQuery.SHOW_IMDBID); } ServiceUtils.setUpImdbButton(imdbId, mImdbButton, TAG, getActivity()); // TVDb final int seasonTvdbId = cursor.getInt(DetailsQuery.REF_SEASON_ID); ServiceUtils.setUpTvdbButton(mShowTvdbId, seasonTvdbId, getEpisodeTvdbId(), mTvdbButton, TAG); // trakt comments mCommentsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), TraktShoutsActivity.class); intent.putExtras(TraktShoutsActivity.createInitBundleEpisode(mShowTvdbId, mSeasonNumber, mEpisodeNumber, mEpisodeTitle)); ActivityCompat.startActivity(getActivity(), intent, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); fireTrackerEvent("Comments"); } }); mEpisodeContainer.setVisibility(View.VISIBLE); }