I need to transfer additional data from an Intent to the calling activity.
The base activity does “startActivityForResult()”.
The nested activity sets the result and puts additional data in a click-listener:
public void onClick(View v) {
setResult(LOGIN_RESULT_IN);
LoginActivity.this.getIntent().putExtra("username", userStr);
LoginActivity.this.getIntent().putExtra("password", passStr);
LoginActivity.this.finish();
}
The calling activity checks the data with:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
preferences.username = data.getStringExtra("username");
preferences.password = data.getStringExtra("password");
}
however this return always null. Why doesn’t it work?
try this code