i am checking networking connection using the below code:
public static boolean haveInternet(Context ctx)
{
NetworkInfo info = (NetworkInfo) ((ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (info == null || !info.isConnected()) {
return false; // no connection
}
return true; // true if having connection
}
Now, on "no connection" , i am launching "Wireless settings" dialog using the below code:
context.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
Here, user is being able to "on/off" the wireless, now how do i come to know whether the user has made "on" the wi-fi or not? i.e. what result is returned by the above intent on the successful wireless connection. how do i check it ?
I think i need to call startActivityForResult method, but dont know how do i do it ?
Update:
I want to do same way as http://groups.google.is/group/android-developers/msg/6874a5e4675dffdb
There is no result. You check it by calling the code you have shown above, or by monitoring relevant broadcast Intents (see
ConnectivityManager
and itsCONNECTIVITY_ACTION
orWifiManager
and itsWIFI_STATE_CHANGED_ACTION
orNETWORK_STATE_CHANGED_ACTION
).That activity does not support
startActivityForResult()
.