Not quite a direct answer to your question, but:

An "ordinary" Android application can enable Wifi subsystem if not already enabled. This requires a special permission. Look up WifiManager.setWifiEnabled().

After enabling Wifi, you can watch broadcast actions defined in WifiManager or ConnectivityManager to know when a connection is established.

-- Kostya

13.08.2010 22:02, KG пишет:
Hi Everyone,

My app requires a network connection so if they don't have one enabled
I prompt them to start it.  I do this by calling the Wireless&
Network settings Activity as such:

startActivityForResult(new
Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS),
NETWORK_RESULT);

However, when I run my app in the debugger, onActivityResult is called
immediately as my calling activity is exited when it should be called
once the settings menu if exited.  This premature call also sends a
resultCode of Activity.RESULT_CANCEL.  Here is the code from
onActivityResult:

if (resultCode == Activity.RESULT_OK) {
                 switch (requestCode) {
                case NETWORK_RESULT:
                        if (!mobileInfo.isConnected()&&  
!wifiInfo.isConnected())
                                noNetwork();
                        else
                                do_something();
                }
}

Does anyone know if I'm doing something wrong?  If I understand this
correctly, onActivityResult should be the callback to when the
Wireless&  Network Settings activity exits.



--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to