I'm trying to pass a string from another activity to this one and then send it into an array and then into a listview. whenever i run this i get "Attempt to invoke virtual method 'android.os.Bundle android.content.Intent.getExtras()' on a null object reference" it seems like the error has something to do with the fourth line with the 'extras' bundle but how is that a null object reference i defined it right there no?
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
Bundle extras = intent.getExtras();
switch(requestCode) {
case ACTIVITY_EDIT:
String title = extras.getString(add.TITLE);
String password = extras.getString(add.PASSWORD);
adapter.add(title);
break;
}
}
Here's where the 'PASSWORD' and 'TITLE' variables are defined in the other Activity:
public void onClick(View v) {
EditText titleBox = (EditText)findViewById(R.id.titleText);
TITLE = titleBox.getText().toString();
EditText passBox = (EditText)findViewById(R.id.passwdText);
String pass = passBox.getText().toString();
EditText confBox = (EditText)findViewById(R.id.editText3);
String conf = confBox.getText().toString();
if (pass.equals(conf)) {
PASSWORD = pass;
this.finish();
} else {
Toast.makeText(this, "Passwords don't match", Toast.LENGTH_SHORT);
}
}