Prevent android wifi network auto switching while debugging - android

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.

Related

Android In app Updates Asking for Wifi while it is on with wifi shared by cell phone

I want to update an android app with android in app update but I have some problem if the phone is connected to a WIFI provided by a cell phone (sharing its cellular network).
In app Update seems to works like this:
When update is found and suggested to the user (firstScreen)
If you are not connected to wifi, you can choose to update the app when wifi will be found or choose to download the update with your cellular data.
if you are already connected to wifi, you don't have this choice (like picture)
When you click on update
If you are connected to wifi coming from cellular network, it's acting like your are waiting for wifi.
It's not a problem in IMMEDIATE update because you could choose to update anyway. But if you have a FLEXIBLE update, it freezes in PENDING status because the phone is waiting for wifi (wifi not from cellular network).
The real problem is that the first screen seems to analyze wifi or and second screen seems to analyze network source.
Maybe because first screen uses NetworkInfo and the second uses NetworkCapability or something.
Does anyone have this problem too?
To prevent user to be blocked when he chose a Flexible update on cellular wifi I will need to found the network source.

Lock a nexus 7 to only one wifi network

We are using a nexus 7 in a very limited way and want some features removed/locked.
One problem we are having is the the device needs to be on a wifi network we set up. Thsi works fine as we save the details for it but if somone accesses the wifi menu and changes the network it will stop the device from working as intended.
Is there a way to set the nexus 7 so that it will not connect to any other wifi network ?
maybe some kind of banned network list ?
This is not an issue of it auto connecting to another network when our network is off but of a user changing the network because they want internet access on the device which we do not want them to have.
The only way to do what you're talking about would be to make your own, custom build of Android that would lock down the features that you don't want.

Programmatically searching and choosing a network provider

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

How can I test android application for network errors?

I have content management application that uses TCP/IP to fetch data. I would like to test this application for several network problems like packet loss and connection lost.
Is there some easy way to emulate network problems to test Android application?
In DDMS there is some connection and latency setting for device, hovewer it looks like this is not working. I can set denied or unregistered but fetching from server is untouched. I'm using Windows for development.
I have tried so far:
F8 - 3G icon disappears, however I'm still able to download data.
DDMS, Change of Telephony status - 3G icon disappears, however I'm still able to download data.
Settings, Mobile networks, Data enabled false - 3G icon disappears, however I'm still able to download
Airplane mode - 3G icon disappears, however I'm still able to download
Dev tools - Wifi toggle - I'm getting errors:
09-27 16:43:31.353: ERROR/Connectivity(518): EVENT_TOGGLE_WIFI
09-27 16:43:31.363: ERROR/WifiService(62): Failed to load Wi-Fi driver.
for testing the lost of internet connexion for example , you can desactivate the 3G connection from your emulator by pressing F8. for example; launch your application , and then while downloading data, try to disable the connection by pressing F8 , and then you can see the reaction of your app
I don't think you have to worry about packet loss with a TCP connection given that the delivery is reliable (lost packets are already handled and re-sent). If you are using an emulator you can set the latency in the Telephony Status section of the Emulator Control tab in DDMS.
You can use Android Dev Tools App.
It's by default on Emulator, and you can copy/install it on real device.
It has option (among others) to toggle Wifi periodically by some given times.

Android loosing connection although the WiFi is still turned on

Backround: Android 2.x on a tablet
That a the second post on this. Now the WiFi don't get turned off by android but I although loose the connectivity after some, means the server can no longer reach the android device (I get a timeout). I tried this at least on four different tablets so I don't think that it depends on the hardware. A continous polling prevent this but this should be just a workaround.
The answer lays in the wifi router AP (access point). There is a value thats called TTL (time to live) which controls how long a connection is held open after last activity before closing from no activity. You need to change this value in the router.

Categories

Resources