what is the reason of the below error
Key Object_list expected Parcelable but value was a java.util.ArrayList. The default value <null> was returned.
this is full code
public class SingleObjectActivity extends Activity
{
public static final String OBJECT_LIST = "Object_list";
private ArrayList<Listitem> Objects;
public ImageView imgview;
private Listitem listObjects;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.singleobject);
Bundle extras = getIntent().getExtras();
imgview = (ImageView) findViewById(R.id.funnyimage);
if (extras.containsKey(OBJECT_LIST)) {
this.listObjects = extras.getParcelable(OBJECT_LIST);
} else {
this.listObjects = null;
}
if (listObjects != null) {
Picasso.
with(getApplicationContext()).
load(listObjects.getUrl())
//load()
.placeholder(R.drawable.logo)
.fit()
.noFade()
.into(imgview);
}
}
}
sending intent
ArrayList<Listitem> personArrayList = new ArrayList<>();
personArrayList.add(new Listitem(item.getOrder(), item.getId(), item.getUrl(), item.getUserName(), item.getLikes()));
Intent intent = new Intent(mcontext,SingleObjectActivity.class);
intent.putExtra("Object_list", personArrayList);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mcontext.startActivity(intent);
edit 4
ArrayList<Listitem> items = getIntent().getParcelableArrayListExtra("Object_list");
Bundle extras = getIntent().getExtras();
imgview = (ImageView) findViewById(R.id.funnyimage);
/* if (extras != null) {
Objects = extras.getParcelableArrayList(OBJECT_LIST);
} else {
Objects = new ArrayList<Listitem>();
}*/
if (extras.containsKey(OBJECT_LIST)) {
// this.listObjects = extras.getParcelable(OBJECT_LIST);
// this.listObjects = (Listitem) extras.getParcelable(OBJECT_LIST);
this.Objects= extras.getParcelableArrayList("Object_list");
} else {
this.Objects = null;
}
if (this.listObjects != null) {
Picasso.
with(getApplicationContext()).
load(this.listObjects.getUrt())
//load()
.placeholder(R.drawable.logo)
.fit()
.noFade()
.into(imgview);
}
}