How do you pass data/parameters to another activit

2020-04-18 07:26发布

How to pass data/parameter values from one activity to another in android?

I have used

loginname=txtloginname.getText().toString();
password=txtpassword.getText().toString();
Bundle bundle = new Bundle();
bundle.putString("loginname", loginname);
bundle.putString("password", password);
Intent newIntent=new Intent();
newIntent.putExtras(bundle);
setResult(RESULT_OK,newIntent);
finish();

But I can only get loginname value How to put both login and password key and value?

2条回答
男人必须洒脱
2楼-- · 2020-04-18 08:06

You can use the method:

getStringExtra()
查看更多
一夜七次
3楼-- · 2020-04-18 08:14

You can just say newIntent.putExtra("name",value); use it multiple times to add multiple data. And depending on the data you stored call getStringExtra("name"); in the next activity.

查看更多
登录 后发表回答