I could get the problem wrong.
What I am doing is showing a warning message when there is no Internet connection, and the ok button leads the user to configure Wi-Fi to turn on the Internet. What I want the application to do when the user returns to it after changing (or not) the Internet settings, restarts the application or activity where it was.
To do this, I make the following call to the ok button:
static void startAct(Activity ctxt)
{
ctxt.startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), WIFI_SETTINGS);
}
in the activity class where this message is shown, I have the following:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == WIFI_SETTINGS && resultCode == RESULT_OK)
{
this.finish();
Intent myIntent = new Intent(this, MyActivity.class);
startActivity(myIntent);
}
}
but resultCode is always 0, onActivityResult is called immediately after clicking the "ok" button.
-? / , Wi-Fi?
, , , , set_result(...), .
!