I am trying to pass user_id value from one Intent to another Intent. I know this is very straight forward process and I have done it several times. But with the below code, I am slightly confuse.
I need to pass user_id value from MainActivity class to MenuFragment class. And the actual flow in the code is like this-
MainActivity will call MenuActivity and MenuActivity will call MenuFragment
So that means, I need to pass user_id value from MainActivity to MenuActivity and then from MenuActivity to MenuFragment. Am I right?
If yes, I am able to pass user_id value from MainActivity class to MenuActivity class but I am not sure how to pass same user_id value from MenuActivity class to MenuFragment class. As the way I am calling MenuFragment class is slightly different so I am not sure how to do that in this case.
Can anyone help me with this?
Below is the MainActivity class
public class MainActivity extends MapActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getIntent().getExtras();
    user_id = bundle.getString("USERID");
    setContentView(R.layout.sample);
    findViewById(R.id.sample_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, getResources()
            .getDisplayMetrics());
        SlideoutActivity.prepare(MainActivity.this, R.id.inner_content, width);
        Bundle bundle = new Bundle();
        bundle.putString("USERID", user_id);
        Intent thesisProject = new Intent(MainActivity.this, MenuActivity.class);
        thesisProject.putExtras(bundle);
        startActivity(thesisProject);
        overridePendingTransition(0, 0);
        }
    });
    }
    }
Below is the MenuActivity class
    public class MenuActivity extends FragmentActivity {
    private SlideoutHelper mSlideoutHelper;
     private String user_id;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getIntent().getExtras();
        user_id = bundle.getString("USERID");
        mSlideoutHelper = new SlideoutHelper(this);
        mSlideoutHelper.activate();
        getSupportFragmentManager().beginTransaction().add(com.korovyansk.android.slideout.R.id.slideout_placeholder, new MenuFragment(), "menu").commit();
        mSlideoutHelper.open();
    }
    ....
}
And below is the MenuFragment class
public class MenuFragment extends ListFragment {
    private String user_id;
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, new String[] { " Settings", " Attributes"}));
        getListView().setCacheColorHint(0);
    }
    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        //get selected items
        String selectedValue = (String) getListAdapter().getItem(position);
        if(selectedValue.equals(" Attributes")) {
            Bundle bundle = new Bundle();
            bundle.putString("USERID", user_id);
            Intent thesisProject = new Intent(getActivity(), MatchingInterest.class);
            thesisProject.putExtras(bundle);
            startActivity(thesisProject);
        }
    }
}
 
     
     
    