I think you are looking for startActivityForResult. You can see a sample of usage in the Android documentation or here on SO.
Basically in your first activity you overwrite the method onActivityResult
and in it (if the result is OK
) re-show the button. Then, in the second activity, set the result to be returned to be OK and just finish it however you like (either by pressing the back button or by calling finish()
).
Alternatively:
You may ovewrite the onResume
method in the first activity and just show the button every time this method is called (note that onResume
is called even on activity's first start, but since the button is already shown in your case - it won't have any effect).
@Override
public void onResume(){
Button b = (Button) findViewById(R.id.myButton);
b.setVisibility(View.VISIBLE);
}