Solution 1 :
try checking if the bundle had been passed or not like this:
Bundle extras = getIntent().getExtras();
if(extras!=null){
if(extras.containsKey("secondUser")){
Log.i("test", "yes");
String[][] cost = (String[][]) extras.getSerializable("secondUser");
}else{
Log.i("test", "no");
}
}
This will not crash your app with NullPointerException
and you will also know if the value has been passed to your activity or not in your logcat.
Problem :
I know that there are already a few posts about this, i tried all of them but nothing worked for me.
As the title says i want to pass a two-dimensional-array to an activity from a fragment, this is my code:
Fragment (passing array):
Intent intent = new Intent(getActivity(), SingleChatActivity.class);
Bundle mBundle = new Bundle();
mBundle.putSerializable("secondUser", requestedFriendships);
intent.putExtras(mBundle);
startActivity(intent);
Activity (receiving array):
Bundle extras = getIntent().getExtras();
String[][] cost = (String[][]) extras.getSerializable("secondUser");
requestedFriendships is here my Array filled with data. As an error i get a NullPointerException.
Does someone have any idea what is wrong or what am i missing? Really grateful for any awnser!