这是来源......
我在将值放入intent时获取空值... 在这里,我从其他活动中获得价值但是当我点击继续
时它会给出空值private Button continue_to_addfriends;
String name = "";
String emailId = "";
String userBirthDate = "";
String password = "";
private Intent j;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_robot_verify);
j = getIntent();
name = (String) j.getStringExtra("name");
emailId = (String) j.getStringExtra("emailId");
userBirthDate = (String) j.getStringExtra("userBirthDate");
password = (String) j.getStringExtra("password");
System.out.println(name+" Robot Activity");
continue_to_addfriends=(Button)findViewById(R.id.button_robot_done);
continue_to_addfriends.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(getApplicationContext(),UsernameverifyActivity.class);
i.putExtra("name", name);
i.putExtra("emailId", emailId);
i.putExtra("userBirthDate", userBirthDate);
i.putExtra("password", password);
System.out.println(password+" Robot intent putting");
startActivity(i);
overridePendingTransition(R.anim.animation,R.anim.animation2);
finish();
}
});
这是日志文件......
![log][1]
答案 0 :(得分:0)
请使用此。
Bundle j= getIntent().getExtras();
name = (String) j.getString("name");
emailId = (String) j.getString("emailId");
userBirthDate = (String) j.getString("userBirthDate");
password = (String) j.getString("password");
我希望它对你有用。