How to use 3G Connection in Android Application instead of Wi-fi?
I want to connect a 3G connection, is there any sample code to connect to 3G instead of Wi-fi?
How to use 3G Connection in Android Application instead of Wi-fi?
I want to connect a 3G connection, is there any sample code to connect to 3G instead of Wi-fi?
This aplication activate 3G and Wifi connection, Giving preference to 3G!! Very useful http://www.redrails.com.br/2012/02/wireless-analyzer-for-android/
@umka
Use connection manager and set network preference as you want.
for example:
There is a missing piece of code on @Northern Captain answer, the DNS lookup code.
Here is a working code:
I think that is not possible from Java. The system shuts down all mobile network based communication if connected to a wireless network. I think that you aren't allowed to start a 3G connection from you program.
Inspired by code in this ticket and using some parts of it, here is service that establishes hipri mobile and keeps it running.
Here is how I start/stop it when needed. Note that it also gets locks on cpu and wifi so that it may run when the phone sleeps (screen only). Wifi is needed because my app is kind of bridge between wifi and mobile connections. You may not need it.
Don't forget to add service to you manifest file.