Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

In this page you can find the example usage for android.os Bundle getParcelable.

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:li.barter.fragments.PasswordResetFragment.java

@Override
public void onSuccess(final int requestId, final IBlRequestContract request, final ResponseInfo response) {
    if (requestId == RequestId.RESET_USER_PASSWORD) {

        final Bundle userInfo = response.responseBundle;

        Utils.updateUserInfoFromBundle(userInfo, true);
        BarterLiApplication.startChatService();

        final Intent returnIntent = new Intent();
        final Bundle arguments = getArguments();
        if (arguments != null && arguments.containsKey(Keys.ONWARD_INTENT)) {
            returnIntent.putExtra(Keys.ONWARD_INTENT, arguments.getParcelable(Keys.ONWARD_INTENT));
        }/*from  w w  w .  ja  v  a  2s .c  om*/

        getActivity().setResult(ActionBarActivity.RESULT_OK, returnIntent);
        getActivity().finish();

    }

}

From source file:com.artemchep.horario.ui.widgets.ChatPanelView.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;

        // Restore root view's params
        Parcelable origin = bundle.getParcelable(STATE_ORIGIN);
        super.onRestoreInstanceState(origin);

        // Restore our params
        String mode = bundle.getString(STATE_MODE, Mode.MESSAGE.name());
        mMode = Mode.valueOf(mode);//from  w w w.j a v  a2  s.  co m
        mModeMessageText = bundle.getString(STATE_MODE_TXT);
        mObject = bundle.getParcelable(STATE_OBJECT);

        setMode(mMode, mObject);
    }
    super.onRestoreInstanceState(state);
}

From source file:org.ohmage.auth.AuthenticatorTest.java

public void testGetAuthToken_userRecoverableErrorWhenAuthtokenFromGoogle_sendsErrorViaIntent()
        throws Exception {
    setAuthTokenCached(false);/*from   ww  w.j  a  va  2 s .co  m*/
    setAccountRefreshToken();
    setAccessTokenFailure(refreshToken, new AuthenticationException(""));
    setHasGoogleAccount(true);
    UserRecoverableAuthException fakeException = new UserRecoverableAuthException("msg", new Intent());
    setGetGoogleAuthTokenResult(fakeException);

    Bundle data = mAuthenticator.getAuthToken(null, fakeAccount, AuthUtil.AUTHTOKEN_TYPE, null);

    Intent intent = data.getParcelable(AccountManager.KEY_INTENT);
    assertNotNull(intent);
    assertEquals(intent.getComponent().getClassName(), AuthenticatorActivity.class.getName());
    assertEquals(fakeException,
            intent.getSerializableExtra(AuthenticatorActivity.EXTRA_HANDLE_USER_RECOVERABLE_ERROR));
}

From source file:com.subzero.runners.android.AndroidLauncher.java

@Override
public void makePurchase(String itemID, Preferences pref) {
    this.pref = pref;
    try {/* w  w  w .  ja  v a2s  .c o  m*/
        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), itemID, "inapp", null);
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                Integer.valueOf(0), Integer.valueOf(0));
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (SendIntentException e) {
        e.printStackTrace();
    }
}

From source file:ch.hesso.master.sweetcity.activity.report.ReportActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    bitmapPicture = savedInstanceState.getParcelable("image");
    ArrayList<Integer> positionList = savedInstanceState.getIntegerArrayList("tagList");
    CurrentTagList.getInstance().putAllFromPositions(tagList, positionList);

    Log.d(Constants.PROJECT_NAME, "positionList " + positionList.toString());

    showTagList();/*from   ww w .java2 s  .c  o m*/
    showPicture();
}

From source file:com.skubit.android.example.MainActivity.java

public void makePurchase(Map<String, String> map) {
    if (mService == null) {
        return;/*from w  w  w.  j a  v a  2  s .c  o  m*/
    }
    try {
        Bundle buyIntent = mService.getBuyIntent(1, getApplicationContext().getPackageName(), map.get("id"),
                "donation", "developerPayload: " + Math.random());
        PendingIntent pendingIntent = buyIntent.getParcelable("BUY_INTENT");

        startIntentSenderForResult(pendingIntent.getIntentSender(), map.get("id").hashCode(), new Intent(), 0,
                0, 0);

    } catch (RemoteException | SendIntentException e) {
        e.printStackTrace();
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.LevelOneActivity.java

private void setupVideoFragment() {
    final Intent intent = getIntent();
    final Bundle bundle = intent.getBundleExtra(EXTRA);
    Validate.notNull(bundle, "The bundle supplied to the activity is null.");
    final String fragmentToShow = bundle.getString(FRAGMENT_TO_SHOW, StringUtils.EMPTY);
    if (SignVideoFragment.class.getSimpleName().equals(fragmentToShow)) {
        final Parcelable sign = bundle.getParcelable(SignVideoFragment.SIGN_TO_SHOW);
        SignVideoFragment signVideoFragment = new SignVideoFragment();
        final Bundle args = new Bundle();
        args.putParcelable(SignVideoFragment.SIGN_TO_SHOW, sign);
        signVideoFragment.setArguments(args);
        setFragment(signVideoFragment, SIGN_VIDEO_TAG);
    } else {// w ww.j a v a2 s. com
        throw new IllegalArgumentException("Cannot show the fragment with name: " + fragmentToShow);
    }
}

From source file:de.golov.zeitgeistreich.ZeitGeistReichActivity.java

/** Called when the activity is first created. */
@Override/*  w ww . ja v a2  s  .  c o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final ImageView imagePreview = (ImageView) findViewById(R.id.ImagePreview);
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    Uri mImageUri = null;
    if (Intent.ACTION_SEND.equals(intent.getAction()) && extras != null) {
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            mImageUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
            if (mImageUri != null) {
                int origId = Integer.parseInt(mImageUri.getLastPathSegment());
                Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(), origId,
                        MediaStore.Images.Thumbnails.MINI_KIND, (BitmapFactory.Options) null);
                imagePreview.setImageBitmap(bitmap);
            }
        }
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,
            tag_suggests);
    final MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.TagEditView);
    textView.setAdapter(adapter);
    textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    final Button button = (Button) findViewById(R.id.ZeitgeistSubmit);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            submitImage(textView.getText().toString());
        }
    });
}

From source file:net.olejon.mdapp.DonateActivity.java

private void makeDonation(String product) {
    try {//w  w w  .j  av  a  2 s  . c om
        Bundle bundle = mIInAppBillingService.getBuyIntent(3, getPackageName(), product, "inapp", "");
        PendingIntent pendingIntent = bundle.getParcelable("BUY_INTENT");

        startIntentSenderForResult(pendingIntent.getIntentSender(), 1, new Intent(), 0, 0, 0);
    } catch (Exception e) {
        new MaterialDialog.Builder(mContext).title(getString(R.string.device_not_supported_dialog_title))
                .content(getString(R.string.device_not_supported_dialog_message))
                .positiveText(getString(R.string.device_not_supported_dialog_positive_button))
                .contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue).show();
    }
}

From source file:com.cloudbees.gasp.activity.GaspRESTLoaderActivity.java

@Override
public Loader<RESTLoader.RESTResponse> onCreateLoader(int id, Bundle args) {
    if (args != null && args.containsKey(ARGS_URI) && args.containsKey(ARGS_PARAMS)) {
        Uri action = args.getParcelable(ARGS_URI);
        Bundle params = args.getParcelable(ARGS_PARAMS);

        return new RESTLoader(this, RESTLoader.HTTPVerb.GET, action, params);
    }// www  . j  ava 2s  .  c  o m

    return null;
}