Example usage for android.content Intent putExtras

List of usage examples for android.content Intent putExtras

Introduction

In this page you can find the example usage for android.content Intent putExtras.

Prototype

public @NonNull Intent putExtras(@NonNull Bundle extras) 

Source Link

Document

Add a set of extended data to the intent.

Usage

From source file:com.bonsai.wallet32.MainActivity.java

@Override
protected void onStart() {
    super.onStart();

    // If the WalletService is already ready and we have
    // an intent uri we should handle that immediately.
    if (mWalletService != null && mWalletService.getState() == WalletService.State.READY) {
        String intentURI = mApp.getIntentURI();
        if (intentURI != null) {
            mApp.setIntentURI(null); // Clear it ASAP.
            Intent intent = new Intent(this, SendBitcoinActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("uri", intentURI);
            intent.putExtras(bundle);
            startActivity(intent);/*from  www  .ja  v  a  2 s .c  o  m*/
        }
    }
}

From source file:net.bible.android.control.link.LinkControl.java

private void showAllOccurrences(String ref, SearchBibleSection biblesection, String refPrefix) {
    Book currentBible = CurrentPageManager.getInstance().getCurrentBible().getCurrentDocument();
    Book strongsBible = null;// w w w .  jav  a2 s  .co m

    // if current bible has no Strongs refs then try to find one that has
    if (currentBible.hasFeature(FeatureType.STRONGS_NUMBERS)) {
        strongsBible = currentBible;
    } else {
        strongsBible = SwordDocumentFacade.getInstance().getDefaultBibleWithStrongs();
    }

    // possibly no Strong's bible or it has not been indexed
    boolean needToDownloadIndex = false;
    if (strongsBible == null) {
        Dialogs.getInstance().showErrorMsg(R.string.no_indexed_bible_with_strongs_ref);
        return;
    } else if (currentBible.equals(strongsBible) && !checkStrongs(currentBible)) {
        Log.d(TAG, "Index status is NOT DONE");
        needToDownloadIndex = true;
    }

    // The below uses ANY_WORDS because that does not add anything to the search string
    //String noLeadingZeroRef = StringUtils.stripStart(ref, "0");
    String searchText = ControlFactory.getInstance().getSearchControl()
            .decorateSearchString("strong:" + refPrefix + ref, SearchType.ANY_WORDS, biblesection, null);
    Log.d(TAG, "Search text:" + searchText);

    Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity();
    Bundle searchParams = new Bundle();
    searchParams.putString(SearchControl.SEARCH_TEXT, searchText);
    searchParams.putString(SearchControl.SEARCH_DOCUMENT, strongsBible.getInitials());
    searchParams.putString(SearchControl.TARGET_DOCUMENT, currentBible.getInitials());

    Intent intent = null;
    if (needToDownloadIndex) {
        intent = new Intent(activity, SearchIndex.class);
    } else {
        //If an indexed Strong's module is in place then do the search - the normal situation
        intent = new Intent(activity, SearchResults.class);
    }

    intent.putExtras(searchParams);
    activity.startActivity(intent);

    return;
}

From source file:br.com.android.cotuca.toptask.Activitys.MSimplesActivity.java

private void selectItem(int posicao) {

    FragmentManager fm = getFragmentManager();

    if (posicao == 0) {
        Fragment f_tarefas = new FragmentTarefas();
        if (idProjetoSelecionado != 0) {
            Bundle dadosProjeto = new Bundle();
            dadosProjeto.putInt(ContratoProjetos.Colunas._ID, idProjetoSelecionado);

            f_tarefas.setArguments(dadosProjeto);
        }/*from  w w  w  . ja  v a2s  . c om*/
        fm.beginTransaction().replace(R.id.content_frame, f_tarefas).commit();

    } else if (posicao == 1) {

        if (!dao.getTarefasDoUsuarioNoProjetos(idProjetoSelecionado, idUsuarioSelecionado).isEmpty()) {

            Intent i = new Intent(this, GraficosActivity.class);
            Bundle dados = new Bundle();
            dados.putInt(Tags.ID_PROJETO, idProjetoSelecionado);
            dados.putInt(Tags.ID_USUARIO, idUsuarioSelecionado);
            i.putExtras(dados);
            startActivity(i);
        } else {
            Log.i("lista de tarefas vazia", "lista de tarefas vazia");
            Toast.makeText(getApplicationContext(), "Voce ainda nao possui tarefas", Toast.LENGTH_SHORT).show();
        }
    } else if (posicao == 2) {
        Intent iSairProjetoAtual = new Intent(this, ProjetosActivity.class);
        Bundle dados = new Bundle();
        dados.putInt(Tags.ID_USUARIO, idUsuarioSelecionado);
        iSairProjetoAtual.putExtras(dados);
        iSairProjetoAtual.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(iSairProjetoAtual);
    }
    mDrawerList.setItemChecked(posicao, true);
    setTitle(mPaginaTitulo[posicao]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:fr.cph.chicago.adapter.SearchAdapter.java

@Override
public final View getView(final int position, View convertView, final ViewGroup parent) {

    LayoutInflater vi = (LayoutInflater) ChicagoTracker.getAppContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = vi.inflate(R.layout.list_search, null);

    TextView rounteName = (TextView) convertView.findViewById(R.id.station_name);

    if (position < mTrains.size()) {
        final Station station = (Station) getItem(position);
        Set<TrainLine> lines = station.getLines();

        rounteName.setText(station.getName());

        LinearLayout stationColorView = (LinearLayout) convertView.findViewById(R.id.station_color);

        int indice = 0;
        for (TrainLine tl : lines) {
            TextView textView = new TextView(mContext);
            textView.setBackgroundColor(tl.getColor());
            textView.setText(" ");
            textView.setTextSize(mContext.getResources().getDimension(R.dimen.activity_list_station_colors));
            stationColorView.addView(textView);
            if (indice != lines.size()) {
                textView = new TextView(mContext);
                textView.setText("");
                textView.setPadding(0, 0,
                        (int) mContext.getResources().getDimension(R.dimen.activity_list_station_colors_space),
                        0);//from   www .j  a  v  a 2  s  . c o  m
                textView.setTextSize(
                        mContext.getResources().getDimension(R.dimen.activity_list_station_colors));
                stationColorView.addView(textView);
            }
            indice++;
        }
        convertView.setOnClickListener(
                new FavoritesTrainOnClickListener(mActivity, mContainer, station.getId(), lines));
    } else if (position < mTrains.size() + mBuses.size()) {
        final BusRoute busRoute = (BusRoute) getItem(position);

        TextView type = (TextView) convertView.findViewById(R.id.train_bus_type);
        type.setText("B");

        rounteName.setText(busRoute.getId() + " " + busRoute.getName());

        final TextView loadingTextView = (TextView) convertView.findViewById(R.id.loading_text_view);
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                loadingTextView.setVisibility(LinearLayout.VISIBLE);
                mActivity.startRefreshAnimation();
                new DirectionAsyncTask().execute(busRoute, loadingTextView);
            }
        });
    } else {
        final BikeStation bikeStation = (BikeStation) getItem(position);

        TextView type = (TextView) convertView.findViewById(R.id.train_bus_type);
        type.setText("D");

        rounteName.setText(bikeStation.getName());

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ChicagoTracker.getAppContext(), BikeStationActivity.class);
                Bundle extras = new Bundle();
                extras.putParcelable("station", bikeStation);
                intent.putExtras(extras);
                mActivity.startActivity(intent);
                mActivity.overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
            }
        });
    }

    return convertView;
}

From source file:com.facebook.android.friendsmash.ScoreboardFragment.java

private void populateScoreboard() {
    // Ensure all components are firstly removed from scoreboardContainer
    scoreboardContainer.removeAllViews();

    // Ensure the progress spinner is hidden
    progressContainer.setVisibility(View.INVISIBLE);

    // Ensure scoreboardEntriesList is not null and not empty first
    if (application.getScoreboardEntriesList() == null || application.getScoreboardEntriesList().size() <= 0) {
        closeAndShowError(getResources().getString(R.string.error_no_scores));
    } else {//from w ww .  ja va  2s.co m
        // Iterate through scoreboardEntriesList, creating new UI elements for each entry
        int index = 0;
        Iterator<ScoreboardEntry> scoreboardEntriesIterator = application.getScoreboardEntriesList().iterator();
        while (scoreboardEntriesIterator.hasNext()) {
            // Get the current scoreboard entry
            final ScoreboardEntry currentScoreboardEntry = scoreboardEntriesIterator.next();

            // FrameLayout Container for the currentScoreboardEntry ...

            // Create and add a new FrameLayout to display the details of this entry
            FrameLayout frameLayout = new FrameLayout(getActivity());
            scoreboardContainer.addView(frameLayout);

            // Set the attributes for this frameLayout
            int topPadding = getResources().getDimensionPixelSize(R.dimen.scoreboard_entry_top_margin);
            frameLayout.setPadding(0, topPadding, 0, 0);

            // ImageView background image ...
            {
                // Create and add an ImageView for the background image to this entry
                ImageView backgroundImageView = new ImageView(getActivity());
                frameLayout.addView(backgroundImageView);

                // Set the image of the backgroundImageView
                String uri = "drawable/scores_stub_even";
                if (index % 2 != 0) {
                    // Odd entry
                    uri = "drawable/scores_stub_odd";
                }
                int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName());
                Drawable image = getResources().getDrawable(imageResource);
                backgroundImageView.setImageDrawable(image);

                // Other attributes of backgroundImageView to modify
                FrameLayout.LayoutParams backgroundImageViewLayoutParams = new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
                int backgroundImageViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_background_imageview_margin_top);
                backgroundImageViewLayoutParams.setMargins(0, backgroundImageViewMarginTop, 0, 0);
                backgroundImageViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    backgroundImageViewLayoutParams.gravity = Gravity.RIGHT;
                }
                backgroundImageView.setLayoutParams(backgroundImageViewLayoutParams);
            }

            // ProfilePictureView of the current user ...
            {
                // Create and add a ProfilePictureView for the current user entry's profile picture
                ProfilePictureView profilePictureView = new ProfilePictureView(getActivity());
                frameLayout.addView(profilePictureView);

                // Set the attributes of the profilePictureView
                int profilePictureViewWidth = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_width);
                FrameLayout.LayoutParams profilePictureViewLayoutParams = new FrameLayout.LayoutParams(
                        profilePictureViewWidth, profilePictureViewWidth);
                int profilePictureViewMarginLeft = 0;
                int profilePictureViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_top);
                int profilePictureViewMarginRight = 0;
                int profilePictureViewMarginBottom = 0;
                if (index % 2 == 0) {
                    profilePictureViewMarginLeft = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_left);
                } else {
                    profilePictureViewMarginRight = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_right);
                }
                profilePictureViewLayoutParams.setMargins(profilePictureViewMarginLeft,
                        profilePictureViewMarginTop, profilePictureViewMarginRight,
                        profilePictureViewMarginBottom);
                profilePictureViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    profilePictureViewLayoutParams.gravity = Gravity.RIGHT;
                }
                profilePictureView.setLayoutParams(profilePictureViewLayoutParams);

                // Finally set the id of the user to show their profile pic
                profilePictureView.setProfileId(currentScoreboardEntry.getId());
            }

            // LinearLayout to hold the text in this entry

            // Create and add a LinearLayout to hold the TextViews
            LinearLayout textViewsLinearLayout = new LinearLayout(getActivity());
            frameLayout.addView(textViewsLinearLayout);

            // Set the attributes for this textViewsLinearLayout
            FrameLayout.LayoutParams textViewsLinearLayoutLayoutParams = new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
            int textViewsLinearLayoutMarginLeft = 0;
            int textViewsLinearLayoutMarginTop = getResources()
                    .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_top);
            int textViewsLinearLayoutMarginRight = 0;
            int textViewsLinearLayoutMarginBottom = 0;
            if (index % 2 == 0) {
                textViewsLinearLayoutMarginLeft = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_left);
            } else {
                textViewsLinearLayoutMarginRight = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_right);
            }
            textViewsLinearLayoutLayoutParams.setMargins(textViewsLinearLayoutMarginLeft,
                    textViewsLinearLayoutMarginTop, textViewsLinearLayoutMarginRight,
                    textViewsLinearLayoutMarginBottom);
            textViewsLinearLayoutLayoutParams.gravity = Gravity.LEFT;
            if (index % 2 != 0) {
                // Odd entry
                textViewsLinearLayoutLayoutParams.gravity = Gravity.RIGHT;
            }
            textViewsLinearLayout.setLayoutParams(textViewsLinearLayoutLayoutParams);
            textViewsLinearLayout.setOrientation(LinearLayout.VERTICAL);

            // TextView with the position and name of the current user
            {
                // Set the text that should go in this TextView first
                int position = index + 1;
                String currentScoreboardEntryTitle = position + ". " + currentScoreboardEntry.getName();

                // Create and add a TextView for the current user position and first name
                TextView titleTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(titleTextView);

                // Set the text and other attributes for this TextView
                titleTextView.setText(currentScoreboardEntryTitle);
                titleTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerNameFont);
            }

            // TextView with the score of the current user
            {
                // Create and add a TextView for the current user score
                TextView scoreTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(scoreTextView);

                // Set the text and other attributes for this TextView
                scoreTextView.setText("Score: " + currentScoreboardEntry.getScore());
                scoreTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerScoreFont);
            }

            // Finally make this frameLayout clickable so that a game starts with the user smashing
            // the user represented by this frameLayout in the scoreContainer
            frameLayout.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_UP) {
                        Bundle bundle = new Bundle();
                        bundle.putString("user_id", currentScoreboardEntry.getId());

                        Intent i = new Intent();
                        i.putExtras(bundle);

                        getActivity().setResult(Activity.RESULT_FIRST_USER, i);
                        getActivity().finish();
                        return false;
                    } else {
                        return true;
                    }
                }

            });

            // Increment the index before looping back
            index++;
        }
    }
}

From source file:com.arcusapp.soundbox.fragment.SongsListFragment.java

private void addRandomButton() {
    // create the button
    Button myButton = new Button(getActivity());
    myButton.setId(19);/*  w  w w.j av  a  2s  .c  om*/
    myButton.setText(this.getString(R.string.LabelPlaySongsRandom));
    myButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    myButton.setCompoundDrawablesWithIntrinsicBounds(null, null,
            getResources().getDrawable(R.drawable.icon_random_shuffled), null);
    myButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //start the playActivity
            Intent playActivityIntent = new Intent();
            playActivityIntent.setAction(SoundBoxApplication.ACTION_MAIN_ACTIVITY);
            playActivityIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            getActivity().startActivity(playActivityIntent);

            //call the service to play new songs
            Intent serviceIntent = new Intent(MediaPlayerService.PLAY_NEW_SONGS, null,
                    SoundBoxApplication.getContext(), MediaPlayerService.class);

            Bundle b = new Bundle();
            Collections.shuffle(songsIDs);
            b.putStringArrayList(BundleExtra.SONGS_ID_LIST, new ArrayList<String>(songsIDs));
            b.putString(BundleExtra.CURRENT_ID, BundleExtra.DefaultValues.DEFAULT_ID);

            serviceIntent.putExtras(b);
            getActivity().startService(serviceIntent);
        }
    });

    // add the button to the header of the list
    myListView.addHeaderView(myButton);
}

From source file:com.neusou.bioroid.restful.RestfulClient.java

/**
 * Sends an Intent callback to the original caller
 * @param ctx// w  ww .j a va2s .  c  o m
 * @param data
 */
public void broadcastCallback(Context ctx, Bundle data, String action) {
    if (ctx != null) {
        //Log.d(LOG_TAG,"broadcastCallback action:"+action);
        Intent i = new Intent(action);
        //i.putExtra(, value);
        i.putExtras(data);

        //runs on the context main thread
        ctx.sendOrderedBroadcast(i, null, mLastCallbackReceiver, null, Activity.RESULT_OK, null, null);

        //ctx.sendBroadcast(i);
    }
}

From source file:com.amytech.android.library.views.imagechooser.api.VideoChooserManager.java

private String captureVideoCurrent() throws Exception {
    checkDirectory();// ww  w.j  a  va 2  s . c o  m
    try {
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        filePathOriginal = FileUtils.getDirectory(foldername) + File.separator
                + Calendar.getInstance().getTimeInMillis() + ".mp4";
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(filePathOriginal)));
        if (extras != null) {
            intent.putExtras(extras);
        }
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        throw new Exception("Activity not found");
    }
    return filePathOriginal;
}

From source file:com.google.appinventor.components.runtime.ProbeBase.java

/**
 * Export the Sensor Database (SensorData as the name for the sqlite db on Android) as
 * csv file(s) or JSON file(s). Each type of sensor data in the database
 * will be export it as one file.//from   w w w . j  av a  2  s.c o m
 * The export path is under SDcard/packageName/export/
 */
@SimpleFunction(description = "Export all sensor data as CSV files")
public void ExportSensorDB() {
    Log.i(TAG, "Exporting DB as CSV files");
    Log.i(TAG, "exporting data...at: " + System.currentTimeMillis());

    Bundle b = new Bundle();
    b.putString(NameValueDatabaseService.DATABASE_NAME_KEY, SensorDbUtil.DB_NAME);
    b.putString(NameValueDatabaseService.EXPORT_KEY, this.exportFormat);
    Intent i = new Intent(mBoundFunfManager, NameValueDatabaseService.class);
    i.setAction(DatabaseService.ACTION_EXPORT);
    i.putExtras(b);
    mBoundFunfManager.startService(i);
}

From source file:gov.wa.wsdot.android.wsdot.ui.FlickrActivity.java

private void showImages() {
    try {// w w  w . jav  a  2 s . co  m
        GridView gridView = (GridView) findViewById(R.id.gridview);
        gridView.setAdapter(this.adapter);
        gridView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                Bundle b = new Bundle();
                Intent intent = new Intent(FlickrActivity.this, FlickrDetailsActivity.class);
                b.putString("title", mFlickrItems.get(position).getTitle());
                b.putString("link", mFlickrItems.get(position).getLink());
                b.putString("content", mFlickrItems.get(position).getContent());
                intent.putExtras(b);
                startActivity(intent);
            }
        });

    } catch (Exception e) {
        Log.e("DEBUG_TAG", "Error getting images", e);
    }
}