发送端:
Message msg = new Message(); Bundle bundle = new Bundle(); Player player = new Player(UserName,UserPass); bundle.putParcelable("person",player); msg.setData(bundle); msg.what=LoginMainPage.SIGN_SUCCESS_BACK; LoginMainPage.mhandler.sendMessage(msg); finish();
接受端:
public static Player callback_player; public static Handler mhandler = new Handler(){ @Override public void handleMessage(@NonNull Message msg) { if (SIGN_SUCCESS_BACK == msg.what) { callback_player = msg.getData().getParcelable("person"); } } }; @Override protected void onResume() { super.onResume(); System.out.println("onResume!"); if(callback_player !=null){ Toast.makeText(this,"Handler传递数据:"+callback_player.user_name,Toast.LENGTH_LONG).show(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)