I am developing an android application in which i want to turn off/on 3G. I have some doubts.
Is it possible to programmatically access 3G data connection?
If it is possible, how to turn off/on 3G data connection without accessing other data connections like 2G etc...?
Is 3G and wifi works at same time?
Which are the different data connections available in android?
Thanks in Advance
There is an unofficial way to turn on/off 3g via reflection. It is not guaranteed to work on all phones so be aware of this. See this answer:
https://stackoverflow.com/a/12535246/1369222
This will not control 3g and 2g separately. This will turn on/off the entire data connection.
Wifi and 3g are not simultaneously connect at the same time. Usually, Wifi is given preference over 3g and the data switches to 3g is wifi connection is lost/unavailable.
The number and types of connections available differs from phone to phone. But most of them do support 2g/3g/wifi.
Related
I have an Android device that has wifi and Bluetooth modules. I want to build applications to connect the device to the internet using a smartphone's data connection. Is this possible?
The smartphone will have wifi as well as data connection. Can the smartphone's data connection be shared through Bluetooth? Or is there better alternatives like wifi-direct or NFC? I am aware that enabling Hotspot on the smartphone is an option. But with hotspot, the issue of wifi being turned off makes it not usable for my use case. Is there any alternative to wifi-hotspot?
What will be the best option for this and what things should I consider when building my applications and services?
NFC is definitely not the answer, the data rate is far too slow and the connection unreliable and the OS does not allow it.
You might be better with a USB ethernet adapter if your phone support USB On The Go (OTG)
Your phone should already support sharing a data connection using Bluetooth. This is called Bluetooth tethering. But you also have wifi, so wifi tethering is also an option to share your data connection. No additional app is required.
We are developing an application that connects to an external device using WIFI, but this external device has no internet access.
In Android M we have realized that the System prioritize a connection with internet access, so the device uses Cellular data to connect internet instead of WIFI.
The problem in that behaviour is that we are not able to access the external device due the device is connected via cellular data instead of WIFI.
Is there anyway to prioritize Wifi connection over cellular data?
Thanks in advance.
I think this is what you are looking for : http://developer.android.com/reference/android/net/ConnectivityManager.html#bindProcessToNetwork(android.net.Network)
And here is similar problem, just the other way around :
How to use data connection instead of WIFI when both are enabled?
I want to create an android application.
Is it possible to send a notification from my phone to other phone which has enabled its WiFi hotspot.
I mean, one phone has enabled its WiFi hotspot and I scanned available WiFi devices and I saw its WiFi hotspot ssid at my available wifi list and I want to send a notification or a message without connect its wifi hotspot point, or using bluetooth or using internet.
Is it possible?
There is also NFC - Near Field Communication. It has nothing to do with Wifi though.
So in theory, yes, I believe you can do what you asked. I think you can react to the presence of the other phones Wifi hotspot, but communicate on NFC instead.
As for sample code, I can't help you. I haven't written anything using NFC.
There is also sms or a phone call
I'm curious is there any way in Android, so I can set my application to use 3G network or not to do it. If 3G is not allowed I need my application to use only Wifi even if there is no available Wifi network.
You can use WifiManager::getConnectionInfo to get info if wifi is connected or not before you make any network calls.
I was wondering does anyone know if its possible to open a wifi and a 3g connection at the same time on Android?
Is there any way to control access to both Wifi and 3g/GPRS data connections and use them at the same time?
At the moment it looks like OS will close the 3G data connection in the moment the wifi gets active.
For some applications it would be very nice to notify the OS that they only want to use the 3G network. This would reduce the number of data connection loss because of leaving and entering bad wifi connections.