I'm passing a string between two fragments. It's working but for a reason i can't get the string outside onStart...
public class EventSelectFriendFragment extends Fragment {
final static String DATA_RECEIVE = "data_receive";
String passedPushId;
Button create;
@Override
public void onStart() {
super.onStart();
Bundle args = getArguments();
if (args != null) {
passedPushId = args.getString(DATA_RECEIVE);
Log.d("passed id",args.getString(DATA_RECEIVE) );
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_event_select_friend, container, false);
create= (Button) rootView.findViewById(R.id.btnCreate);
btnMaakEvent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
for(int i = selectedFriends.size()-1 ; i >= 0; i--){
Log.d("array: ", i + selectedFriends.get(i).getFirstName());
Log.d("passedPushId: ", passedPushId);
}
}
});
return rootView;
}
}
In onStart passedPushId gives me the string from the other fragment. But when i want to use it in a for loop the passedPushId is null...