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:com.business.rushour.businessapp.RiderMainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // if the result is capturing Image
    if (requestCode == PICK_IMAGE_REQUEST) {
        if (resultCode == RESULT_OK) {
            fileUri = data.getData();/*w  w  w  .j a v a 2s. co  m*/
            // successfully captured the image
            // display it in image view
            previewCapturedImage();
        }
    }

    else if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            previewCapturedImage();
        }
    }

    else if (requestCode == PIC_CROP) {
        // user cancelled Image capture
        Bundle extras = data.getExtras();
        //get the cropped bitmap
        Bitmap thePic = extras.getParcelable("data");

        //ImageView imageView = (ImageView) findViewById(R.id.fullimageview);
        CircularImageView uploadphoto = (CircularImageView) findViewById(R.id.CircularImageViews);
        uploadphoto.setImageBitmap(thePic);
    }
}

From source file:com.appunite.helpers.EditFragment.java

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

    Intent intent = getActivity().getIntent();
    String action = intent.getAction();

    mDiscard = false;//w  w w .  ja  va2 s .  c  o m

    if (savedInstanceState != null) {
        mUri = savedInstanceState.getParcelable(STATE_URI);
        checkState(mUri != null);
        mIsEdit = savedInstanceState.getBoolean(STATE_IS_EDIT);
    } else if (Intent.ACTION_INSERT.equals(action) || Intent.ACTION_INSERT_OR_EDIT.equals(action)) {
        mUri = intent.getData();
        if (mUri == null) {
            mUri = getInsertionUri();
        }
        checkArgument(mUri != null);
        mIsEdit = false;
    } else if (Intent.ACTION_EDIT.equals(action)) {
        mUri = intent.getData();
        checkArgument(mUri != null);
        mIsEdit = true;
    } else {
        throw new IllegalArgumentException("Unknown action: " + action);
    }
}

From source file:com.binomed.showtime.android.screen.widget.results.CineShowTimeResultsWidgetActivity.java

@Override
protected void onPreRestoreBundle(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        boolean saved = savedInstanceState.getBoolean(ParamIntent.BUNDLE_SAVE, false);
        if (saved) {
            getModelActivity().setNearResp((NearResp) savedInstanceState.getParcelable(ParamIntent.NEAR_RESP));
            getModelActivity().setForceResearch(
                    savedInstanceState.getBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST, false));
            intentResult = new Intent();
            intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST, false);
            String cityName = savedInstanceState.getString(ParamIntent.ACTIVITY_SEARCH_CITY);
            intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_CITY, cityName);
            getModelActivity().setCityName(cityName);
            Double latitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE, 0);
            Double longitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE, 0);
            if ((latitude != 0) && (longitude != 0)) {
                intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_LATITUDE, latitude);
                intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_LONGITUDE, longitude);
                Location location = new Location("GPS");
                location.setLatitude(latitude);
                location.setLongitude(longitude);
                getModelActivity().setLocalisation(location);
            }/*www.ja va 2s  .c  o m*/
        }

    }
}

From source file:com.akop.bach.fragment.xboxlive.SentMessagesFragment.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);

    if (mAccount == null) {
        Bundle args = getArguments();
        ContentResolver cr = getActivity().getContentResolver();

        mAccount = (XboxLiveAccount) args.getParcelable("account");
        mTitleId = getFirstTitleId(cr.query(SentMessages.CONTENT_URI, new String[] { SentMessages._ID, },
                SentMessages.ACCOUNT_ID + "=" + mAccount.getId(), null, SentMessages.DEFAULT_SORT_ORDER));
    }/* w  w  w.ja va2 s. c om*/

    if (state != null && state.containsKey("account")) {
        mAccount = (XboxLiveAccount) state.getParcelable("account");
        mTitleId = state.getLong("titleId");
    }

    setHasOptionsMenu(true);
}

From source file:com.example.ridemedriver.SignupStepTwoActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    Log.i("WWQQ", "in onActivityResult()");
    switch (requestCode) {
    case 1:/* w w  w  . j a v  a 2 s .c  om*/
        if (resultCode == RESULT_OK) {
            cropPhoto(data.getData());//?
        }
        break;
    case 2:
        if (resultCode == RESULT_OK) {
            File temp = new File(Environment.getExternalStorageDirectory() + "/head.jpg");
            cropPhoto(Uri.fromFile(temp));//?
        }
        break;
    case 3:
        if (data != null) {
            Bundle extras = data.getExtras();
            avatar_pic = extras.getParcelable("data");
            if (avatar_pic != null) {
                FileOutputStream b = null;
                File file = new File(path);
                file.mkdirs();// 
                String fileName = path + "upload_avata";//??
                try {
                    b = new FileOutputStream(fileName);
                    avatar_pic.compress(Bitmap.CompressFormat.JPEG, 100, b);// ?
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } finally {
                    try {
                        //?
                        b.flush();
                        b.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                signup_steptwo_avatar_imgview.setImageBitmap(avatar_pic);//ImageView?
            }
        }
        break;
    default:
        break;

    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.business.rushour.businessapp.RiderMainActivity.java

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

    // get the file url
    fileUri = savedInstanceState.getParcelable("file_uri");
}

From source file:br.com.brolam.cloudvision.ui.helpers.ActivityHelper.java

/**
 * Recupear os states view somente dos state view salvos.
 * @param savedInstanceState/*from  w  ww  .j a  va 2s .co m*/
 */
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    assert savedInstanceState != null;
    if (savedInstanceState.containsKey(COORDINATOR_LAYOUT_HELPER_VIEW_STATE)) {
        this.coordinatorLayoutHelperViewState = savedInstanceState
                .getParcelable(COORDINATOR_LAYOUT_HELPER_VIEW_STATE);
    }

    if (savedInstanceState.containsKey(RECYCLER_VIEW_STATE)) {
        this.recyclerViewState = savedInstanceState.getParcelable(RECYCLER_VIEW_STATE);
    }

    if (savedInstanceState.containsKey(NESTED_SCROLL_HELPER_VIEW_STATE)) {
        this.nestedScrollHelperViewState = savedInstanceState.getParcelable(NESTED_SCROLL_HELPER_VIEW_STATE);
    }

    if (savedInstanceState.containsKey(ITEM_SELECTED_KEY)) {
        setItemSelectedKey(savedInstanceState.getString(ITEM_SELECTED_KEY));
    }
}

From source file:cn.xcom.helper.activity.AuthorizedActivity.java

/**
 * ????/*from w ww .j  a  va 2 s. c  om*/
 *
 * @param data
 */
private void getImageToView(Intent data) {
    Bundle extras = data.getExtras();
    if (extras != null) {
        Bitmap photo = extras.getParcelable("data");
        storeImageToSDCARD(photo);
    } else {

    }
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.PostFragment.java

/**
 * Initializes several of the member variables used
 * by PostFragment./*from  w ww  .j  a  v a2  s  .  com*/
 * @param savedInstanceState The previously saved state of the fragment.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    locationListenerService = new LocationListenerService(getActivity());
    locationListenerService.startListening();
    Bundle args = getArguments();
    if (args.getLong("id") != -1) {
        commentToReplyTo = (Comment) args.getParcelable("cmt");
        boolean fromFavs = args.getBoolean("fromFavs");
        if (fromFavs) {
            FavouritesLog log = FavouritesLog.getInstance(getActivity());
            thread = log.getThreads().get((int) args.getLong("id"));
        } else {
            thread = ThreadList.getThreads().get((int) args.getLong("id"));
        }
    }
}

From source file:ca.rmen.android.networkmonitor.app.prefs.PreferenceFragmentActivity.java

@Override
public void onOkClicked(int actionId, Bundle extras) {
    Log.v(TAG, "onClicked, actionId=" + actionId + ", extras = " + extras);
    mUserInput = true;/*  w  w w.ja  v a2  s.  co  m*/
    // Import the database in a background thread.
    if (actionId == ID_ACTION_IMPORT) {
        final Uri uri = extras.getParcelable(EXTRA_IMPORT_URI);
        AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {

            @Override
            protected void onPreExecute() {
                DialogFragmentFactory.showProgressDialog(PreferenceFragmentActivity.this,
                        getString(R.string.progress_dialog_message), ProgressDialog.STYLE_SPINNER,
                        PROGRESS_DIALOG_FRAGMENT_TAG);
            }

            @Override
            protected Boolean doInBackground(Void... params) {
                try {
                    Log.v(TAG, "Importing db from " + uri);
                    DBImport.importDB(PreferenceFragmentActivity.this, uri);
                    return true;
                } catch (Exception e) {
                    Log.e(TAG, "Error importing db: " + e.getMessage(), e);
                    return false;
                }
            }

            @Override
            protected void onPostExecute(Boolean result) {
                ProgressDialogFragment dialogFragment = (ProgressDialogFragment) getSupportFragmentManager()
                        .findFragmentByTag(PROGRESS_DIALOG_FRAGMENT_TAG);
                if (dialogFragment != null)
                    dialogFragment.dismissAllowingStateLoss();
                String toastText = result ? getString(R.string.import_successful, uri.getPath())
                        : getString(R.string.import_failed, uri.getPath());
                Toast.makeText(PreferenceFragmentActivity.this, toastText, Toast.LENGTH_SHORT).show();
                finish();
            }
        };
        task.execute();
    } else if (actionId == ID_ACTION_LOCATION_SETTINGS) {
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        startActivity(intent);
        finish();
    }
}