Adroid中的两个Activity用Intent来传递实体

 

跳转至LoginActivity

Intent intent = new Intent();
intent.setClass(MenuActivity.this, LoginActivity.class);
startActivityForResult(intent, LoginCode);

 

LoginActivity处理页

Intent intent=new Intent();
intent.putExtra("UserModel", model);
setResult(RESULT_OK, intent);
finish();

MenuActivity处理结果

@Override
protected void onActivityResult(int sendcode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(sendcode, resultCode, data );

switch(sendcode)
{
case LoginCode:

if(resultCode==RESULT_OK)
{
UserModel uModel = (UserModel)data.getParcelableExtra("UserModel");

}
break;
}
}

posted @ 2015-01-23 14:21  文艺流浪汉  阅读(176)  评论(0编辑  收藏  举报