Android Bundle - Gives different param values

35 views Asked by At

Description:

I am passing values from activity to DialogFragment with help of bundle. I need to fetch/get those values from bundle for my further process.

Problem: I do not get passed values but I get some other key-value pair which i did not pass/used. - Mapping Issue

Code:

Activity

MyDialogFragment dialogFragment = new MyDialogFragment();

    Bundle bundleValues = null;
// val1 and val2 are pin values
        bundleValues = new Bundle();
        bundleValues.putString(Params.PIN_VALUE,pinDate);
        bundleValues.putString(Params.PIN_VALUE_1,val1);
        bundleValues.putString(Params.PIN_VALUE_2,val2);

    dialogFragment.setArguments(bundleValues);
    dialogFragment.show(getSupportFragmentManager(),"values");

Code in MyDialogFragment

Bundle bundle = getArguments();
if (bundle != null) {


        if (bundle.getString(Params.PIN_VALUE) != null) {
            String pinVal = bundle.getString(Params.PIN_VALUE);
            mPinVal.setText(pinVal);
        }

        if (bundle.getString(Params.PIN_VALUE_1) != null) {
            String pinVal1 = bundle.getString(Params.PIN_VALUE_1);
            mPinVal1.setText(pinVal1);
        }


        if (bundle.getString(Params.PIN_VALUE_2) != null) {
            String pinVal2 = bundle.getString(Params.PIN_VALUE_2);
            mPinVal2.setText(pinVal);
        }

    }

In MydialogFragment post bundle = getArguments() i get below values in bundle as below in image:

enter image description here

0

There are 0 answers