There is a way to do this from code:
http://developer.android.com/reference/android/net/wifi/WifiManager.html#enableNetwork(int,
boolean)
public boolean enableNetwork (int netId, boolean disableOthers)
Since: API Level 1
Allow a previously configured network to be associated with. If
disableOthers is true, then all other configured networks are
disabled, and an attempt to connect to the selected network is
initiated. This may result in the asynchronous delivery of state
change events.
For this to work, you first need to add the network to Android's "known"
(== configured) network list, that's how you get the "int netId" above.
http://developer.android.com/reference/android/net/wifi/WifiManager.html#addNetwork(android.net.wifi.WifiConfiguration)
Add a new network description to the set of configured networks. The
networkId field of the supplied configuration object is ignored.
The new network will be marked DISABLED by default. To enable it,
called enableNetwork(int, boolean).
The only somewhat tricky part is setting correct security options in the
WifiConfiguration object. Here is how I do it in my application:
http://kmansoft.wordpress.com/2010/04/08/adding-wifi-networks-to-known-list/
You can also check the sources of Android's Settings application,
available here:
http://android.git.kernel.org/?p=platform/packages/apps/Settings.git;a=summary
-- Kostya
25.01.2011 12:24, Marcin Orlowski пишет:
On 25 January 2011 09:59, Brijesh<[email protected]> wrote:
Hi,
I want to connect my android device to a wifi point which is having a
WPA key is there any method in which i can pass the SSID and password
and the device will connect to that wifi-point.???
Tell your user to set the phone up for this network?
--
Kostya Vasilyev -- 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