【发布时间】:2021-07-13 22:03:55
【问题描述】:
我正在编写通过 Intent 发送和接收数据的代码
但是,代码总是在以下方面存在问题: 总结结果
请问,谁能帮帮我?
发送数据的代码:
``` nextPage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent senderIntent = new Intent(getApplicationContext(), UserRegistration2.class);
Bundle sendlerBundler = new Bundle();
sendlerBlundler.putString("summaryResult", summaryResult);
senderIntent.putExtras(sendlerBundler);
startActivity(senderIntent);
Toast.makeText(getApplicationContext(), "It was sent: " + summaryResult, Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), UserRegistration2.class);
startActivity(intent);
Bundle param = new Bundle();
param.putString("name", name);
param.putString("birthDate", birthDate);
parame.putString("city", city);
param.putString("summaryResult", summaryResult);
senderIntent.putExtras(param);
startActivity(senderIntent);
startActivity(intent);
}
});```
接收数据的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.userRegistration);
Intent receiverIntent = getIntent();
Bundle receiverBundle = receiverIntent.getExtras();
String summaryResult =
receiverBundle.
getString
**("summaryResult");**
Toast.makeText(UserRegistration.this, "Receiving the Summary Result: " +summaryResult, Toast.LENGTH_LONG).show();```
【问题讨论】: