代码:
发送
Intent intent = new Intent(this, MainActivity2.class);
//创建一个新的包裹,类似sessoin
Bundle bundle = new Bundle();
int user_id = mHelper.findid(user_name);
System.out.println("id = " + user_id);
bundle.putString("user_id", String.valueOf(user_id));
intent.putExtras(bundle);
startActivity(intent);
接收
Bundle bundle = getIntent().getExtras();标签:bundle,Intent,user,跳转,数据传输,intent,id From: https://www.cnblogs.com/JIANGzihao0222/p/17185895.html
user_id = bundle.getString("user_id");
System.out.println(user_id);
总结:和javaweb的session类似,通过传播一个包裹传输,然后在另一个界面去接受,去获取