I have an activity where the user press a button and then is send to a fragment, but I wish to pass an extra for the use of the fragment:
activity A(where is the button):
public OnClickListener publish = new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),ActivityB.class);
intent.putExtra("friendIdRowID", rowID);
startActivity(intent);
}
};
Activity B is loading the fragment(where I wish to retrieve the extra "friendIdRowID"), the fragment:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_main2, container, false);
Bundle extras = getActivity().getIntent().getExtras();
if (extras != null)
{
String myString = extras.getString("friendIdRowID");
}
}
But it is not working, what can I do to pass and retrieve the extra? thanks.