Make an activity A wait an activity B finish to continue
Edit: I may have misunderstood your question. If you want to run checkSettings() function in B then you need to define and call that function in your B activity.
Otherwise, if you want to wait for activity B to end before running checkSettings() then copy the following code.
In A:
public void onSettingsClick(View view){
Intent intent = new Intent(this, Settings.class);
startActivityForResult(intent, 1);
}
then also in A Override
onActivityResult
method.. this gets called when B ends:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
checkSettings();
}
In your Activity A write
public void onSettingsClick(View view){
Intent intent = new Intent(this, Settings.class);
startActivityForResult(intent, 100);
}
and also in you Activity A override onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==RESULT_OK){
if(requestCode==100){
checkSettings();
}
}
}
and in your Activity B
when you want to finish that activity write that piece of code there
Intent returnIntent = new Intent();
setResult(RESULT_CANCELED, returnIntent);
finish();