我正在尝试在活动之间进行简单的信息转换。问题是,在收到的活动中,我陷入了get.Extras() == null
下面是接收活动代码:
helloName = (TextView) findViewById(surfaceName);
Bundle extra = getIntent().getExtras();
String nome = extra.getString("keyName");
System.out.println(nome) ; #PRINTING =null
helloName.setText("Olá "+nome);
这是我的传递信息活动:
Editable nome = name.getText();
System.out.println(nome);
Intent intent = new Intent(HelloActivity.this, MainActivity.class);
intent.putExtra("keyName",nome);
System.out.println(intent.getExtras());
startActivity(intent);
试试
Editable nome = name.getText();
System.out.println(nome);
Intent intent = new Intent(HelloActivity.this, MainActivity.class);
intent.putExtra("keyName",nome.toString());
System.out.println(intent.getExtras());
startActivity(intent);