我有 3 个活动
活动1 活动2 活动3
这里的代码:
活动1:
Intent intent= new Intent(Activity1.this,Acivity2.class);
Bundle b=new Bundle();
b.putParcelableArrayList("actionArray", (ArrayList<? extends Parcelable>) AllListArray.get(0));
b.putParcelableArrayList("comedyArray", (ArrayList<? extends Parcelable>) AllListArray.get(1));
intent.putExtras(b);
startActivity(intent);
活动2:
//get the Bundle of movie category data data from previous activity
Bundle recdData = getIntent().getExtras();
actionArray=recdData.getParcelableArrayList("actionArray");
comedyArray=recdData.getParcelableArrayList("comedyArray");
public void btnClicker(View v)
{
Intent i= new Intent(getApplicationContext(), Activity3.class);;
Bundle b=new Bundle();
switch(v.getId())//get the button label id from respective View
{
case R.id.actionBtn:
b.putParcelableArrayList("movieCategorie", (ArrayList<? extends Parcelable>) actionArray);
b.putString("movieCategorieDisplay","Action Movies");
i.putExtras(b);
startActivity(i);
break;
case R.id.comedyBtn:
b.putParcelableArrayList("movieCategorie", (ArrayList<? extends Parcelable>) comedyArray);
b.putString("movieCategorieDisplay","Comedy Movies");
i.putExtras(b);
startActivity(i);
break;
活动3:
backButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), Acivity2.class);
i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
CategoryListView.this.startActivity(i);
}
});
问题是当我在我的 Activity3 中单击返回按钮(在移动返回按钮上)时,有时会出现 NullPionterException
Activity2中这一行的异常点
actionArray=recdData.getParcelableArrayList("actionArray");
任何人都可以帮助我吗?