Sunday, June 20, 2010

Re: [android-developers] Re: How to set Connection mode?

If your intention is to disconnect from WiFi, so the phone switches to
mobile data network, you can do it like this:

Get an instance of WifiManager

Either: disable WiFi altogether, using wifimanager.setWifiEnabled(false)

Or disconnect from the current network:

WifiInfo wfi = wifimanager.getConnectionInfo();
if (wfi != null) {
int networkId = wfi.getNetworkId();
if (networkId != -1) {
wifimanager.disableNetwork(networkId);
}
}

-- Kostya

20.06.2010 22:25, reda пишет:
> Hi,
>
> Can anybody please tell us if it is possible to change network
> connection programmatically ? How can we do a fail over ?
>
>
> If no, when it will be available ?
>
>
> Thanks
>
>
>
> On 29 avr, 15:45, vikky<vikash19852...@gmail.com> wrote:
>
>> Hi..
>> thnx for the reply..
>> I have tried so many things...but not able to activate the otherconnectionmode..
>> i tried this..
>> setNetworkPreference(ConnectivityManager.TYPE_WIFI)
>>
>> but it is not working asking for permission again and again..and i
>> provided all the permission..listed below..
>>
>> <uses-permission android:name="android.permission.READ_PHONE_STATE"></
>> uses-permission>
>> <uses-permission
>> android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-
>> permission>
>> <uses-permission
>> android:name="android.permission.ACCESS_NETWORK_STATE"></uses-
>> permission>
>> <uses-permission
>> android:name="android.permission.CHANGE_NETWORK_STATE"></uses-
>> permission>
>> <uses-permission android:name="android.permission.WRITE_SETTINGS"></
>> uses-permission>
>> <uses-permission
>> android:name="android.permission.WRITE_SECURE_SETTINGS"></uses-
>> permission>
>> <uses-permission
>> android:name="android.permission.WRITE_APN_SETTINGS"></uses-
>> permission>
>>
>> However it is not working..
>> plz suggest me..
>> is it possible to chenge theconnectionmode of a mobile(from
>> TYPE_WIFI to TYPE_MOBILE) by program??
>> Thanks a lot...
>>
>> On Apr 27, 7:30 pm, Martin Obreshkov<manig...@gmail.com> wrote:
>>
>>
>>
>>
>>
>>
>>> Take a look athttp://developer.android.com/reference/android/net/ConnectivityManage...
>>> .
>>>
>>
>>> On Tue, Apr 27, 2010 at 9:38 AM, vikky<vikash19852...@gmail.com> wrote:
>>>
>>>> Hi all,
>>>>
>>
>>>> I want to provide option to users...forConnectionmode with web
>>>> server for services(XML)..
>>>> How can i set theconnectionto use
>>>> Wi-Fi or
>>>> Direct or
>>>> MDS or
>>>> WAPconnectionmode..
>>>> Is there any way to set theconnectionto use SSL?
>>>> plz help me..
>>>>
>>
>>>> Thanks..
>>>> Vikky
>>>>
>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Android Developers" group.
>>>> To post to this group, send email to android-developers@googlegroups.com
>>>> To unsubscribe from this group, send email to
>>>> android-developers+unsubscribe@googlegroups.com<android-developers%2Bunsubs cribe@googlegroups.com>
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/android-developers?hl=en
>>>>
>>
>>> --
>>> When I raise my flashing sword, and my hand takes hold on judgment, I will
>>> take vengeance upon mine enemies, and I will repay those who haze me. Oh,
>>> Lord, raise me to Thy right hand and count me among Thy saints.
>>>
>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-developers@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> android-developers+unsubscribe@googlegroups.com
>>> For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en
>>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscribe@googlegroups.com
>> For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en
>>
>


--
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment