我正在尝试使用Parceler在两个Activites之间发送一个List。这就是我一直在努力做的事情:
Intent intent = new Intent(SearchServices.this, MainActivity.class);
intent.putExtra(SearchServices.PARCELER_TAG,Parcels.wrap(
new Services(Arrays.asList(sortedArrayr)) ));
startActivity(intent);
sortedArrayr
是DataSnapshot
Intent intent = this.getIntent();
Log.e("onCreate: ", Parcels.unwrap(intent.getParcelableExtra(SearchServices.PARCELER_TAG)).toString() );
Parceler类
@Parcel(Parcel.Serialization.BEAN)
public class Services {
List<DataSnapshot> ser;
public Services(List<DataSnapshot> ser) {
this.ser = ser;
}
public Services() {
}
}
但我不断得到NullPointerException
:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference