I wrote a custom static method to create my fragment. Fragment is a subclass of android.support.v4.app.Fragment class.
Method to create my fragment is bellow.
public static AddItemFragment newInstance(UUID listId, UUID itemId){
AddItemFragment fragment=new AddItemFragment();
Bundle bundle=new Bundle();
bundle.putSerializable(EXTRA_DATA_LIST_ID,listId);
bundle.putSerializable(EXTRA_DATA_ITEM_ID, itemId);
fragment.setArguments(bundle);
return fragment;
}
In my onCreate method, I am attempting to read data from bundle.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mListId = (getArguments().getSerializable(EXTRA_DATA_LIST_ID) == null ? null : (UUID) getArguments().getSerializable(EXTRA_DATA_LIST_ID));
mItemId = (getArguments().getSerializable(EXTRA_DATA_ITEM_ID) == null ? null : (UUID) getArguments().getSerializable(EXTRA_DATA_ITEM_ID));
}
Well the problem is that getArguments() method never returns bundle. It always returns NULL. I don't understand why. savedInstanceState is NULL as well.