I'm currently developping an application that resets your connection when your signal strength is too low.
I'm trying to do this by searching and choosing your network operator (settings-> wireless and networks -> Mobile networks -> Network operators).
I noticed this way has a few advantages over switching to airplane mode:
- Wifi and/or bluetooth doesn't get disabled
- You don't 'loose' your reception and this can still make calls (tested this; you will still lose your data/internet connection, however)
I'm trying to find some way to automate this when your signal drops too low.
Does anyone know how to do this (preferably without root, but if needed, that's fine as well; Busybox shell commands are fine too)?
Thanks
Related
I'm developing an app that uses the server in the wifi network (A), which has no internet connection. I use another wifi connection (B) with the internet for normal use. When I debug my app, I switch my android phone to the wifi connection A.
but the wifi network automatically changes to B, while I'm still debugging my app which has no programmatic functionality to change the wifi connection. If I change it back to A, after a few seconds or about in one-two minutes it automatically changes back to B. This is not an expected behavior to me since I can't properly debug my app.
I tried to change the network & internet settings, but no option was found to prevent automatic wifi network switching. What I can guess is my wifi B is selected by android O/S because it has an internet connection. I can forget that connection, but it's not practical because I use both connections in short time periods.
I wonder if any other developer solved this kind of problem in any programmatic or manual way while debugging. I really do not want to include any wifi switching functionality in my app, just need to keep my wifi connection A connected while debugging with Android Studio.
My Android O/S version is 10, Nokia 3.1
Any help would be highly appreciated.
In my flutter app, I need to get information from a device via wifi as a stream. Also I need to keep my google maps online via Mobile internet. How can I use both wifi and mobile network at the same time in my phone. I made a lot of search but I can't find any solution for this.
I don't think it's possible.
The phone would need two network antennas and possibly two network adapters.
You can surely toggle both wifi and mobile data at the same time and they can probably switch frequently to optimize your connection or send requests to different services.
But you can't really use them both at the same time.
(if it's possible) I don't recommend it, since a majority of phones will not support this feature since you need two network antennas.
From the facts as presented, there are a couple of possible solutions, but they aren't perfect and I'm guessing on one as I haven't tested it yet.
One, Google Maps has an offline mode. You can set it up to download maps for offline use. It will show your position on the maps whether you are connected to the internet or not, but you won't get traffic data or accurate travel times. Not great, but it can work.
Two, it is possible for a phone to have a WiFi network and Cellular network active at the same time, but not in the way everyone seemed to think. Since you are wanting the cellular connection open to have access to the internet, I'm assuming this is because the WiFi network you want to access doesn't have the internet. So, reverse the WiFi network. Setup your phone to be a hotspot network, it runs its own WiFi network while maintaining access to the internet through its cellular network. I'm guessing here, but unless phones have some specific security protocol forbidding it I don't know about (which can be the case), your app should be able to contact anything connected to its phone's WiFi while still having access to the internet.
If this doesn't work for some reason, you can try a trick I used when I set up a car office. Get a mobile hotspot device. It's a device you can put a cellular SIMM in and it creates a WiFi hotspot. You can connect to it, along with other devices in the car. All will being using WiFi and the hotspot will provide the internet access.
If what you are connected to can only create a WiFi network for you to access and it can't be configured to connect to one itself, you could technically still be able to do it by network switching. Much harder to do (probably impossible on some devices) and will likely mess with other apps depending on internet access, so a real break glass in case of emergency type of situation there.
What signal (that is turned on permanently or most of the time) of our phones can another phone detect?
For example, if we turn on BLE then another phone is able to detect it using their BLE. However, people do not tend to leave their phone's BLE on all the time.
So, what else can I use?
Besides Bluetooth, your only other options are WiFi and NFC. However, similar to Bluetooth, WiFi and NFC can be turned of for long periods of time to save power (e.g. airplane mode). Moreover, not all phones support NFC or expose API to use it.
I would say your best bet is WiFi due to its more frequent use (relative to Bluetooth and NFC). It still has restrictions though and I would say Bluetooth is more suitable for your purpose. Below you can find a list of links that might be useful for your research:-
iOS API to scan WiFi networks
iOS - How to programmatically connect to a WiFi network given the SSID and password
Android WiFiManager
Android connecting to devices wirelessly
I hope this helps.
I have an app that needs to connect to a hardware via Wi-Fi. For this purpose, the hardware offers an offline Wi-Fi Hotspot. The hotspot's DHCP doesn't give us a gateway or DNS so we know right away, that it's for offline use only.
The end user will be at work and have to stay connected to the Wi-Fi the whole time in order to receive sensor data and alerts if something is wrong with the data. But at the same time, we don't want to force the end user to be offline with his mobile device. He should be able to use his mobile data for our and all other apps he has.
I though I can control this by calling android.net.ConnectivityManager.requestNetwork. But it doesn't seem to work reliably. Will calling requestNetwork in my app influence if all the other apps have access to mobile data?
Is this even something that we can control? I tested this on multiple devices with different manufacturers and android versions and they all behave differently.
E.g. Pixel 3a works fine. After some time I get a notification regarding the offline Wi-Fi. If I ignore it, it keeps working. If I press "yes" on it, I am offline and connected to the Wi-Fi.
Huawei P20 Lite seems to fire a OnLost event for my mobile data NetworkCallback every time I request it. Like its trying to cancel the mobile connection every time I reconnect because I'm in the wifi. Some devices offer a "Smart Switch" (Samsung) or "Wi-Fi+" (Huawei) mode which isn't on per default. And it seems like a hassle to ask the user to turn it on, since they might not want to use it in different scenarios.
Here are some examples for the different devices:
When using requestNetwork() to stick to an offline wifi network, you need an instance of ConnectivityManager. You can get it as follows:
final ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
This method returns the OS's connectivity manager. Therefore other apps will also be impacted by the "sticky" mode you've put the ConnectivityManager in.
Unfortunately I don't think it's possible for an app to force OS to stay connected to an offline Wifi network, and at the same time keep using mobile data.
After trying this out on various devices, I can say, that it is not possible to achive the desired behaviour consinstently on all devices.
Pretty much all the devices, behave differently. The OS-version is not really a factor. It depends more on how the vendors handle the case, that a user is connected to an offline wifi.
Based on the device, it might be possible to stay connected to offline wifi and use mobile data at the same time for all apps. But the OS can automatically disconnect you or lock you into the offline-wifi and disable mobile data. Maybe it does it because the user selected an option in the system dialogs as shown above.
In the latter case, it is possible to force a mobile data connection with the ConnectivityManager for the own app. But it is not possible to make all the other apps use this mobile connection as well.
How to enable WiFi and to make list of the devices found after searching for wifi connectivity in android phone ?
Android devices could not originally do this without an access point in between, except by rooting and directly manipulating the network settings to permit ad-hoc wireless. However a few newer devices seem to support it.
Android Wifi direct multiple connection ad-hoc
(Arguably this could be closed as a duplicate of that, but I thought there was room for more explanation than found there. There was another recent question too, but I can't find it)
If one device supports wifi tethering that can be enabled and the other connect to it, but then all network traffic from the other device would go through it, potentially using up the data plan (ie, okay for two devices with the same owner, not a good idea for casual transfers)
The "standard" solution would still be to use a wifi access point, and potentially to do the transfer via an Internet server as intermediary, which has the side benefit of not needing the devices to be on the same network.