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.google.appinventor.components.runtime.ProbeBase.java

protected void saveToDB(IJsonObject completeProbeUri, IJsonObject data) {

    Log.i(TAG, "Writing data: " + completeProbeUri + ": " + data.toString());
    final JsonObject dataObject = data.getAsJsonObject();
    dataObject.add("probe", completeProbeUri.get(RuntimeTypeAdapterFactory.TYPE));
    dataObject.add("timezoneOffset", new JsonPrimitive(localOffsetSeconds)); // nice
    // move//from  w  ww  . j  a va2  s.c om
    final long timestamp = data.get(BaseProbeKeys.TIMESTAMP).getAsLong();
    final String probeName = completeProbeUri.get("@type").getAsString();

    Bundle b = new Bundle();
    b.putString(NameValueDatabaseService.DATABASE_NAME_KEY, PROBE_BASE_NAME);
    b.putLong(NameValueDatabaseService.TIMESTAMP_KEY, timestamp);
    b.putString(NameValueDatabaseService.NAME_KEY, probeName);
    b.putString(NameValueDatabaseService.VALUE_KEY, dataObject.toString());
    Intent i = new Intent(mBoundFunfManager, NameValueDatabaseService.class);
    i.setAction(DatabaseService.ACTION_RECORD);
    i.putExtras(b);
    mBoundFunfManager.startService(i);

}

From source file:com.parse.ParsePushBroadcastReceiver.java

/**
 * Called when the push notification is opened by the user. Sends analytics info back to Parse
 * that the application was opened from this push notification. By default, this will navigate
 * to the {@link Activity} returned by {@link #getActivity(Context, Intent)}. If the push contains
 * a 'uri' parameter, an Intent is fired to view that URI with the Activity returned by
 * {@link #getActivity} in the back stack.
 *
 * @param context/*from ww w  .  j a  v  a  2 s.c  o  m*/
 *      The {@code Context} in which the receiver is running.
 * @param intent
 *      An {@code Intent} containing the channel and data of the current push notification.
 */
protected void onPushOpen(Context context, Intent intent) {
    // Send a Parse Analytics "push opened" event
    ParseAnalytics.trackAppOpenedInBackground(intent);

    String uriString = null;
    try {
        JSONObject pushData = new JSONObject(intent.getStringExtra(KEY_PUSH_DATA));
        uriString = pushData.optString("uri", null);
    } catch (JSONException e) {
        PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
    }

    Class<? extends Activity> cls = getActivity(context, intent);
    Intent activityIntent;
    if (uriString != null) {
        activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString));
    } else {
        activityIntent = new Intent(context, cls);
    }

    activityIntent.putExtras(intent.getExtras());
    /*
      In order to remove dependency on android-support-library-v4
      The reason why we differentiate between versions instead of just using context.startActivity
      for all devices is because in API 11 the recommended conventions for app navigation using
      the back key changed.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilderHelper.startActivities(context, cls, activityIntent);
    } else {
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(activityIntent);
    }
}

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

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Bundle b = new Bundle();
    Intent intent = new Intent(getActivity(), FacebookDetailsActivity.class);
    b.putString("createdAt", mFacebookItems.get(position).getCreatedAt());
    b.putString("text", mFacebookItems.get(position).getMessage());
    b.putString("htmlText", mFacebookItems.get(position).getmHtmlFormattedMessage());
    intent.putExtras(b);

    startActivity(intent);// w  w  w. j a va2 s.  co m
}

From source file:com.dwdesign.tweetings.fragment.ConversationFragment.java

public void linkGenerationComplete(String url) {
    if (isShare == false) {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        bundle.putString(INTENT_KEY_TEXT, url);
        intent.putExtras(bundle);
        startActivity(intent);/*from w  w w  .  j  a  va 2  s . c  o  m*/
    } else {
        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, url);
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
    }
}

From source file:com.bellman.bible.android.control.link.LinkControl.java

private void showAllOccurrences(String ref, SearchBibleSection biblesection, String refPrefix) {
    Book currentBible = getCurrentPageManager().getCurrentBible().getCurrentDocument();
    Book strongsBible = null;/*from   w ww .j ava  2s .c  o  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:de.lespace.apprtc.activity.ConnectActivity.java

private void connectToUser() {

    Intent newIntent = new Intent(this, CallActivity.class);
    newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    newIntent.putExtra("keep", true);
    newIntent.putExtras(intent);
    startActivityForResult(newIntent, CONNECTION_REQUEST);

}

From source file:com.cssweb.android.quote.QHHQActivity.java

private void loadAllStock(final int position) {
    Intent localIntent = new Intent();
    if (position == 0) {
        localIntent.setClass(QHHQActivity.this, ZJS.class);
        Bundle extras = new Bundle();
        extras.putInt("stocktype", 201);
        extras.putString("market", "cffex");
        extras.putString("exchange", "cf");
        extras.putString("title", "");
        localIntent.putExtras(extras);

    } else if (position == 1) {
        localIntent.setClass(QHHQActivity.this, SQS.class);

        Bundle extras = new Bundle();
        extras.putInt("stocktype", 201);
        extras.putString("market", "sfe");
        extras.putString("exchange", "sf");
        extras.putString("title", "");
        extras.putInt("type", R.array.sqs_type_menu);
        localIntent.putExtras(extras);/*  w w  w.  j  av a  2 s  . c o m*/
    } else if (position == 2) {
        localIntent.setClass(QHHQActivity.this, DSS.class);

        Bundle extras = new Bundle();
        extras.putInt("stocktype", 201);
        extras.putString("market", "dce");
        extras.putString("exchange", "dc");
        extras.putString("title", "");
        extras.putInt("type", R.array.dss_type_menu);
        localIntent.putExtras(extras);
    } else if (position == 3) {
        localIntent.setClass(QHHQActivity.this, ZSS.class);

        Bundle extras = new Bundle();
        extras.putInt("stocktype", 201);
        extras.putString("market", "czce");
        extras.putString("exchange", "cz");
        extras.putString("title", "");
        extras.putInt("type", R.array.zss_type_menu);
        localIntent.putExtras(extras);
    } else if (position == 4) {
        localIntent.setClass(QHHQActivity.this, QQSP.class);
    }
    startActivity(localIntent);
}

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

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Bundle b = new Bundle();
    Intent intent = new Intent(getActivity(), BlogDetailsActivity.class);
    b.putString("title", blogItems.get(position).getTitle());
    b.putString("content", blogItems.get(position).getContent());
    b.putString("link", blogItems.get(position).getLink());
    intent.putExtras(b);

    startActivity(intent);/*  w ww . j  av  a 2s .  c  om*/
}

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

@Override
protected void onWalletStateChanged() {
    if (mWalletService == null)
        return;//from  w  w w  . j  a v  a2s  . c  o  m

    switch (mWalletService.getState()) {
    case SETUP:
    case WALLET_SETUP:
    case KEYS_ADD:
    case PEERING:
        // All of these states use a progress dialog.
        if (mStateProgressDialog != null)
            updateStateMessage(mWalletService.getStateString());
        else
            showStateProgressDialog(mWalletService.getStateString());
        break;
    case SYNCING:
        if (mStateProgressDialog != null) {
            mStateProgressDialog.dismissAllowingStateLoss();
            mStateProgressDialog = null;
        }

        if (mSyncProgressDialog == null)
            showSyncProgressDialog();

        int pctdone = (int) mWalletService.getPercentDone();

        String timeLeft = formatTimeLeft(mWalletService.getMsecsLeft());

        updateSyncStats(String.format("%d%%", pctdone), String.format("%d", mWalletService.getBlocksToGo()),
                mDateFormatter.format(mWalletService.getScanDate()), timeLeft);

        if (mSyncDialogView != null) {
            ProgressBar pb = (ProgressBar) mSyncDialogView.findViewById(R.id.progress_bar);
            pb.setProgress(pctdone);
        }
        break;
    case READY:
        if (mStateProgressDialog != null) {
            mStateProgressDialog.dismissAllowingStateLoss();
            mStateProgressDialog = null;
            mStateDialogView = null;
        }

        if (mSyncProgressDialog != null) {
            mSyncProgressDialog.dismissAllowingStateLoss();
            mSyncProgressDialog = null;
            mSyncDialogView = null;
        }

        // Did we have an intent uri? (Sent from another application ...)
        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);
        }
        break;
    case SHUTDOWN:
        break;
    case ERROR:
        break;
    }

    updateBalances();
}

From source file:com.redhorse.quickstart.AppAll.java

public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2, final long arg3) {
    // TODO Auto-generated method stub
    //      ResolveInfo info = mApps.get(position);
    ///*  w ww  .  ja v  a2 s .  c om*/
    //      Intent i = getIntent();
    //      Bundle b = new Bundle();
    //      b.putString("msg", "open");
    //      b.putString("packageName", info.activityInfo.packageName);
    //      b.putString("name", info.activityInfo.name);
    //      i.putExtras(b);
    //      this.setResult(RESULT_OK, i);
    //      dbStart.close();
    //      this.finish();

    // TODO Auto-generated method stub
    AlertDialog opDialog = new AlertDialog.Builder(AppAll.this).setTitle("")
            .setItems(R.array.select_dialog_items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    /* User clicked so do some stuff */
                    String[] items = getResources().getStringArray(R.array.select_dialog_items);
                    ResolveInfo info = null;
                    ResolveInfo selectedinfo = null;
                    switch (which) {
                    case ITEM_ID_DELETE:
                        selectedinfo = mApps.get(arg2);
                        String packageName = selectedinfo.activityInfo.packageName;
                        String name = selectedinfo.activityInfo.name;
                        Iterator it1 = mAllApps.iterator();
                        while (it1.hasNext()) {
                            info = (ResolveInfo) it1.next();
                            if (packageName.equals(info.activityInfo.packageName)
                                    && name.equalsIgnoreCase(info.activityInfo.name)) {
                                Intent intent = new Intent();
                                Uri packageURI = Uri.parse("package:" + packageName);
                                Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
                                startActivityForResult(uninstallIntent, STARTUNINSTALL_REQUEST);
                                break;
                            }
                        }
                        break;
                    case ITEM_ID_OPEN:
                        info = mApps.get(arg2);
                        Intent i = getIntent();
                        Bundle b = new Bundle();
                        b.putString("msg", "open");
                        b.putString("packageName", info.activityInfo.packageName);
                        b.putString("name", info.activityInfo.name);
                        i.putExtras(b);
                        AppAll.this.setResult(RESULT_OK, i);
                        dbStart.close();
                        AppAll.this.finish();
                        break;
                    }
                }
            }).create();
    opDialog.show();

}