我想将字符串从活动传递到其他活动。例如,告诉我有 5 个活动我从第二个到第三个到第四个到第五个得到一个文本,但是当我单击一个按钮转到第三个时,文本没有保存当我通过时如何保存字符串它?
我尝试通过 Intent 将我从第二个活动中获得的文本传递给所有其他人:
//While on MainActivity
Intent Second = new Intent(MainActivity.this, SecondActivity.class);
startActivity(Second);
//While on SecondActivity
Intent Third = new Intent(SecondActivity.this, ThirdActivity.class);
Third.putExtra("Third", String);
startActivity(Third);
//While on ThirdActivity
TextView String;
String = findViewByID(R.id.TextView1);
String.setText(string);
String string = getIntent().getStringExtra("Third");
Intent Forth = new Intent(ThirdActivity.this, ForthActivity.class);
Forth.putExtra("Forth", string);
startActivity(Forth);
我一直在传递这样的字符串,直到 Activity 5 有一个按钮可以转到第三个并且 textview 文本没有保存
我希望当我单击活动 5 中转到第三个活动的按钮时,第三个活动上的文本视图将成为我传递的第二个活动的文本。