android - How can I know that the activity is return from system setting page? -
the main activity :
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); setcontentview(r.layout.logo); tools.checknetword(logoactivity.this); }
when activity starts ,it check out there's availabe network
public static void checknetword(final context context) { if (!tools.isnetworkavailabe(context)) { new alertdialog.builder(context).seticon(r.drawable.hi).settitle(r.string.logo_dialog_title).setmessage(r.string.set_network) .setpositivebutton(r.string.ok, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialoginterface, int i) { //跳转到设置界面 context.startactivity(new intent(settings.action_wireless_settings)); } }).setnegativebutton(r.string.cancel, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialoginterface, int i) { ((activity)context).finish(); } }).create().show(); } }
so user may click positive button ,and brougt system setting page. when reset network , click button. go activity. should do?that want go on check if network ok. use onrestart method? seems no work...
use method startactivityforresult(intent, int)
, implement onactivityresult(int, int, intent)
. read more here
Comments
Post a Comment