Is it possible to connect the emulator to Wi-fi? Since am not using eclipse or any IDE... Am trying to connect a stand alone emulator to Wi-fi
Currently, while you can use your computer's Internet connection in the emulator, it's not reliable to use it for simulating Wi-Fi. The WifiManager gets confused when you switch/want to test your connectivity state.
Even in Android 1.5, there were some problems with it (Issue 2571 - android), and while you can use your Internet for simulating HTTP connections and downloading data, finer control over Wi-Fi connectivity should better be done with a device.
If you mean that the emulator should connect to the internet via your PC/MAC then it works without any changes.
I am able to browser the internet via the browser in the emulator i.e. the emulator has internet connectivity.
Related
I have a webserver that is running on a network that is not connected to the internet.
The webserver serves up a website.
When I connect an android phone to it, I am able to run the website that is on the webserver
But with certain phones that are running Android 11 I need to disable the mobile data on the phone before it will try to access the website over wifi. It seems the phone will not try to request the url on the wifi network because it doesn't have internet, so it defaults to using the 4G/5G Cellular internet connection. This is too bad, because I would like the phone to use the wifi connection.
I would think that perhaops I could "force" the phone to use the wifi connection by typing the IP address in the browser's URL bar (eg. http://192.168.211.1/index.php), however it seems that even with the "local ip" it will still try to use the 4G/5G network instead of the "offline wifi" network.
The only workaround I have found is to disable moblie data on the phone, but this is not ideal.
I would think that some IoT devices would have an offline webserver used for configuation/control.
Is there a certain port or settings I should be using?
Is there a designated port that the browser/OS would expect to be on an offline network?
Basically, how can I make the phone use the wifi, even though the wifi is not connected to the internet?
Thanks so much for any pointers!
Android studio has its own settings for connection. There I can use proxy. So this way studio will use that proxy instead of computer wifi connection to sync libraries for example.
But for example if my application I send requests to the firebase what connection will be used by emulator? It will use studio proxy or it will use computer wifi for that? And if I use real device will it use mobile internet connection or proxy?
I have tested all scenarios. So the answers are the following.
Everything local depends on local WIFI of the laptop. Android studio has opportunity to set up its own proxy but also wount work without wifi. Android emulator has a wifi spot calls AndroidWifi in settings which indicates laptop wifi.
The real device use its own connection. So these are to separate different parts. If there is no connection on laptop but there is on real device. So you can't add library but you can launch based on HTTP requests app on real device.
I've setup a racoon server on my linux router. It was working ok with my xperiaz (C6603) road warrior. However after I applied the latest update to android 4.4.2 (firmware 10.5.A.0.230) it stopped working correctly. I have ping from the phone to each ip (local ip or internet) but when I use FQDN it can't be resolved. I can ping the phone from within my local network too. VPN is IPSec Xauth RSA. Checking with adb DNS server is correctly set:
getprop net.dns1
192.168.6.1
I also tried pushing the same ip as dns2 but no change. I also noticed that after closing the connection to the vpn server net.dns1 remains 192.168.6.1 however the phone is able to correctly resolve addresses. In few minutes it gets changed back to my 3g provider setting.
I tried to redirect all traffic through the tunnel via the advanced vpn setting (Forwarding routes = 0.0.0.0/0) and tried to set DNS statically via the same settings (DNS servers = 192.168.6.1). Even setting the DNS server to my provider's DNS addres didn't work which makes me think the problem is with the android itself.
DNS server is working as far as I can tell:
$ dig #192.168.6.1 dir.bg +short
194.145.63.12
Forwarding is enabled on my router so shouldn't be the problem. I've read about a bug in android but it's in android 2.x and seems to impact wifi connections.
Have you seen similar problems and as I'm not an expert with android and adb, can you tell me what commands are available in adb/shell to trace the problem? Phone is not rooted and it's not possible for the moment to root it.
UPDATE:
the tunnel is working ok when I connect via wifi hotspot. The problem appears to show only via my 3g carrier. Any ideas how to work around this?
After updating to 4.4.4 I still got the same problem. Further testing revealed that the problem is more likely to be in the Android rather than my 3g carrier. Over wifi the VPN worked flawlessly after using wifi tethering from another phone via the same provider it worked ok again so my 3g carrier isn't blocking anything.
Yesterday I finally rooted my phone and installed SDFix to restore full access to my SD card. Now VPN is working ok again even via 3g. I hope someone can confirm/reject that solution as I see no relation between vpn and sd card at all. However I experienced initially the problem with my update to 4.4.2 where Sony started to follow Google's policy about storage access.
Is it possible to test wifi related tests on Android Emulator. That means in my application I have a scenario which will search a particular wifi network available and then connect to it entering password in the password field. Is it possible using Emulator only. Can it be done so that Emulator will access the wifi adapter of laptop and the available networks will be shown in the search list in Emulator.
N:B
I am using Robotium version 4.3 with ADT.
No, this is not possible.
There is no APIs to access the system WiFi adaptor.
Unfortunately, you can't enable WiFi on your android Emulator because the emulator is actually a virtual OS running on pc, which is using your laptop/pc WiFi connection.
If you want to search for WiFi networks, you better search on a real device.
I'm designing an Android app that will require the use of a web server on the local device. I've been trying out some different servers for this purpose. At present I haven't written any code or run anything in an emulator, just played around with the servers on my actual phone, and I'm observing some strange behaviour.
Whenever I try to connect to the local web server, and I have WIFI switched off, the HTTP request fails. If I switch WIFI on, it succeeds.
Depending on which address I use, I get different results: using localhost or 127.0.0.1, I get connection refused when WIFI is off; using the current 10.X.Y.Z address I get a timeout. Both addresses work when WIFI is on.
I have tried this with xWS, PAW and i-Jetty: the behaviour is consistent. WIFI on, I can connect to the local web server; WIFI off, I can't.
I am using the default "Internet" browser on Android 2.3.3 on a Samsung Galaxy S (GT-I9000).
Does anyone know why this is? Is it a simple question of a setting somewhere I need to change, or what's going on?
Cheers,
/Uffe
Can you change the network interface the web server is connected to?
The default setting is probably something like eth0 or wlan0, if you change it to lo it could work.
You are asking why when you turn off your wifi, there is no connection to the 10.0.0.2 (Your computer's localhost) and when you turn it on, there is a connection?
Very simple. Wifi off - NO INTERNET connection. The device emulator is a separate OS inside your computer's OS. When you turn off your WIFI there is no route to the host (your computer) - there is no internet
I have now tested with my own simple client, and with Opera - and it works.
So in fact this is an issue not with the IP stack but with the default Android browser, or possibly with the settings enforced by the manufacturer (Samsung) or carrier (Telenor Sweden). Either way there is a workaround: use Opera instead.
Still don't know why it doesn't work with the default browser, but I'll mark this question answered.