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.dwdesign.tweetings.fragment.BaseUserListsListFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUserList == null)
        return false;
    switch (item.getItemId()) {
    case MENU_VIEW_USER_LIST: {
        openUserListDetails(getActivity(), mAccountId, mSelectedUserList.list_id, mSelectedUserList.user_id,
                mSelectedUserList.user_screen_name, mSelectedUserList.name);
        break;//from ww w.j av  a 2s  .  co  m
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_USER_LIST, mSelectedUserList);
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    }
    return true;
}

From source file:com.parse.ParseAnalyticsTest.java

private Intent makeIntentWithParseData(String pushHash) throws JSONException {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    JSONObject json = new JSONObject();
    json.put("push_hash", pushHash);
    bundle.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, json.toString());
    intent.putExtras(bundle);
    return intent;
}

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

public void restoreWallet(View view) {
    mLogger.info("restore wallet");

    NetworkParameters params = Constants.getNetworkParameters(getApplicationContext());

    String filePrefix = "wallet32";

    EditText hextxt = (EditText) findViewById(R.id.seed);
    EditText mnemonictxt = (EditText) findViewById(R.id.mnemonic);

    String hexseedstr = hextxt.getText().toString();
    String mnemonicstr = mnemonictxt.getText().toString();

    // Did the user specify *both* hex seed and mnemonic?
    if (hexseedstr.length() > 0 && mnemonicstr.length() > 0) {
        showErrorDialog(mRes.getString(R.string.restore_bothbad));
        return;/*w  w w .  j  a  v a  2s  .  c  om*/
    }

    byte[] seed;

    // Did we have a hex seed?
    if (hexseedstr.length() > 0) {
        try {
            seed = Hex.decode(hexseedstr);
        } catch (Exception ex) {
            showErrorDialog(mRes.getString(R.string.restore_badhexvalue));
            return;
        }
        if (seed.length % 8 > 0) {
            showErrorDialog(mRes.getString(R.string.restore_badhexlength));
            return;
        }
    }

    // How about a mnemonic string?
    else if (mnemonicstr.length() > 0) {
        MnemonicCodeX mc;
        try {
            InputStream wis = getApplicationContext().getAssets().open("wordlist/english.txt");
            mc = new MnemonicCodeX(wis, MnemonicCodeX.BIP39_ENGLISH_SHA256);
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        List<String> words = new ArrayList<String>(Arrays.asList(mnemonicstr.trim().split("\\s+")));
        try {
            seed = mc.toEntropy(words);
        } catch (MnemonicException.MnemonicLengthException ex) {
            showErrorDialog(mRes.getString(R.string.restore_badlength));
            return;
        } catch (MnemonicException.MnemonicWordException ex) {
            String msg = mRes.getString(R.string.restore_badword, ex.badWord);
            showErrorDialog(msg);
            return;
        } catch (MnemonicException.MnemonicChecksumException ex) {
            showErrorDialog(mRes.getString(R.string.restore_badchecksum));
            return;
        }
    }

    // Hmm, nothing specified?
    else {
        showErrorDialog(mRes.getString(R.string.restore_noseed));
        return;
    }

    EditText ppEditText = (EditText) findViewById(R.id.passphrase);
    String passphrase = ppEditText.getText().toString();

    // How many accounts to restore?
    int numaccts;
    try {
        EditText numacctedittxt = (EditText) findViewById(R.id.numaccounts);
        String numacctsstr = numacctedittxt.getText().toString();
        numaccts = Integer.parseInt(numacctsstr);
    } catch (NumberFormatException ex) {
        showErrorDialog(mRes.getString(R.string.restore_badnumaccts));
        return;
    }

    MnemonicCodeX.Version bip39version;
    HDStructVersion hdsv;
    RadioGroup hdsrg = (RadioGroup) findViewById(R.id.format_choice);
    switch (hdsrg.getCheckedRadioButtonId()) {
    default:
    case R.id.format_v0_5:
        hdsv = HDWallet.HDStructVersion.HDSV_STDV1;
        bip39version = MnemonicCodeX.Version.V0_6;
        break;
    case R.id.format_v0_4:
        hdsv = HDWallet.HDStructVersion.HDSV_STDV0;
        bip39version = MnemonicCodeX.Version.V0_6;
        break;
    case R.id.format_v0_3:
        hdsv = HDWallet.HDStructVersion.HDSV_L0PRV;
        bip39version = MnemonicCodeX.Version.V0_6;
        break;
    case R.id.format_v0_2:
        hdsv = HDWallet.HDStructVersion.HDSV_L0PUB;
        bip39version = MnemonicCodeX.Version.V0_6;
        break;
    case R.id.format_v0_1:
        hdsv = HDWallet.HDStructVersion.HDSV_L0PUB;
        bip39version = MnemonicCodeX.Version.V0_5;
        break;
    }

    WalletApplication wallapp = (WalletApplication) getApplicationContext();

    // Setup a wallet with the restore seed.
    HDWallet hdwallet = new HDWallet(wallapp, params, wallapp.mKeyCrypter, wallapp.mAesKey, seed, passphrase,
            numaccts, bip39version, hdsv);
    hdwallet.persist(wallapp);

    // Spin up the WalletService.
    Intent svcintent = new Intent(this, WalletService.class);
    Bundle bundle = new Bundle();
    bundle.putString("SyncState", "RESTORE");
    svcintent.putExtras(bundle);
    startService(svcintent);

    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);

    // Prevent the user from coming back here.
    finish();
}

From source file:com.android.together.BaseActivity.java

/** BundleAction **/
protected void startActivity(String action, Bundle bundle) {
    Intent intent = new Intent();
    intent.setAction(action);//from   w ww .j a  v  a2  s.c  o m
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    startActivity(intent);
}

From source file:com.android.together.BaseActivity.java

/** BundleClass **/
protected void startActivity(Class<?> cls, Bundle bundle) {
    Intent intent = new Intent();
    intent.setClass(this, cls);
    if (bundle != null) {
        intent.putExtras(bundle);
    }/*from  ww  w. j a  v a2 s  .  c o  m*/
    startActivity(intent);
}

From source file:cn.robertzhang.libraries.base.BaseFragmentActivity.java

/**
 * startActivity with bundle//from w  ww .j  av a2 s  .  c  o  m
 *
 * @param clazz
 * @param bundle
 */
protected void readyGo(Class<?> clazz, Bundle bundle) {
    Intent intent = new Intent(this, clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivity(intent);
}

From source file:cn.robertzhang.libraries.base.BaseFragmentActivity.java

/**
 * startActivityForResult with bundle//w  w w  .j a  v  a 2  s . co m
 *
 * @param clazz
 * @param requestCode
 * @param bundle
 */
protected void readyGoForResult(Class<?> clazz, int requestCode, Bundle bundle) {
    Intent intent = new Intent(this, clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivityForResult(intent, requestCode);
}

From source file:cn.robertzhang.libraries.base.BaseFragmentActivity.java

/**
 * startActivity with bundle then finish
 *
 * @param clazz/*from   www  .  j  av a  2 s  . c  om*/
 * @param bundle
 */
protected void readyGoThenKill(Class<?> clazz, Bundle bundle) {
    Intent intent = new Intent(this, clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivity(intent);
    finish();
}

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

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUser == null)
        return false;
    switch (item.getItemId()) {
    case MENU_VIEW_PROFILE: {
        openUserProfile(mSelectedUser.user_id, mSelectedUser.screen_name);
        break;/*  w  ww  . jav a2 s. com*/
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_USER, mSelectedUser);
        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(mSelectedUser)) {
            list.add(mSelectedUser);
        }
        break;
    }
    }
    return true;
}

From source file:com.parse.ParseAnalyticsTest.java

@Test
public void testGetPushHashFromIntentEmptyPushHashIntent() throws Exception {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    JSONObject json = new JSONObject();
    json.put("push_hash_wrong_key", "test");
    bundle.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, json.toString());
    intent.putExtras(bundle);

    String pushHash = ParseAnalytics.getPushHashFromIntent(intent);

    assertEquals("", pushHash);
}