In a given activity, an AlertDialog takes the user into WiFI settings. Then, the user presses the back button to return to said activity.
However, as soon as the back button has been pressed I need to make a method call. Please note that I cannot simply add the method after the following code in the activity, as this will impact the time the user has to interact with the AlertDialog instance.
The method call needs to happen as soon as the back button has been pressed form the WIFI settings menu. Please inform me of how I can implement this.
Here is the code:
alertDialog.setPositiveButton("Settings", new dialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
startActivity(intent);
}
});
You can Override
the onResume()
method of the calling Activity
. As soon soon as the user presses the "back" button
the onResume()
method is sure to get called so you should be able to put your method call here