I want to send the text entered by the user from current activity (which is LIKE A DIALOG BUT NOT ONE). Activity 1 is in the background and running. I have attempted this as of now:
Second Activity Code:
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
if(companyNameEditText.getText().toString()!=null) {
intent.putExtra("companyName", companyNameEditText.getText().toString());
nameChanged=true;
finish();
}
else{
Toast.makeText(ChangeNameActivity.this,"Please enter a value",Toast.LENGTH_SHORT).show();
}
}
});
onDestroy for second Activity:
@Override
protected void onDestroy() {
super.onDestroy();
if(nameChanged)
{
activityFinishedWithChanges= true;
}
}
First Activity's on Resume:
@Override
protected void onResume() {
super.onResume();
if(ChangeNameActivity.activityFinishedWithChanges) {
companyNameText = findViewById(R.id.companyNameText);
if (getIntent().hasExtra("companyName")) {
String companyName = getIntent().getStringExtra("companyName");
if (companyName != null) {
if (!companyName.equals("")) {
companyNameText.setText(companyName);
AppUtils.setNameSharedPreference(BrandSettingsActivity.this, AppConstants.organizationName, getIntent().getStringExtra("companyName"));
}
}
}
}
}
I'm getting a null value in my case.