I am making a local web app. Users will connect through WiFi and all DNS requests result IP of my server. Windows PCs and phones check http://www.msftncsi.com/ncsi.txt for check internet connectivity. So I made a simple text file with that name and they think it is OK.
I have problem with Android and iOS smartphones. Specially iOS, It disconnect WiFi if user ignores its alert.
I think android phones connect to mtalk.google.com:5228 to check notifications and other things.
How can i fool them?
"Basically, it’s the Network connectivity status indicator (NCSI) service that does the trick..."
You can see at: http://www.nextofwindows.com/how-windows-7-knows-my-network-connection-status
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!
I can't find any documentation on Android Wear that shows how to create an app that leverages the fact that some watches (like my Samsung Galaxy Gear) can now connect directly to the internet via wi-fi when the phone is not around.
I have a few apps that generate https requests to access a REST service and I would like to know if these can be directly called from a Wear app connected to wi-fi (no phone).
Similar questions don't seem to answer this:
Direct internet connection on Android Wear?
https://stackoverflow.com/questions/26062487/android-wi-fi-direct-persistent-connection
Android: Establish "Wi-Fi Direct" connection with networked devices
My tests on a Wear emulator tethered to an internet enabled Phone emulator show:
java.net.UnknownHostException: Unable to resolve host "api.xxx.com": No address associated with hostname
But of course there's no direct wi-fi connection on the watch emulator so my next step is to try on a real watch and phone.
My suspicion is that Android Wear's data API handles this transparently so direct http requests seem impossible.
Best, thanks in advance for your help.
Even if Android 5.1.1 support Wi-Fi Feature. Android Wear on Wi-Fi: Using a smartwatch without a phone nearby
You should stick to the Data Layer API, you cannot send http request directly from watch. Fetch internet data from the phone, then transfer it to watch with Data Layer API.
You can see this Does Android Wear support directly access the Internet?
And this document Always-on and Wi-Fi with the latest Android Wear update
From the last update its possible to make http requests over wifi using android wear. You can even connect a bluetooth headphone to it to use with some streaming app.
While on wifi, if your mobile phone is connected to the internet too (dont need to be the same wifi, can be even 3g) it will act the same way it would when bluetooth connected yo our phone, but with its own internet access.
This dont mean apps will change their behavior, because most of them are coded to make the requests from your phone, but if you have an app that make direct networks requests, it will send them from your watch without advising or needing your phone.
How to do networks requests on android wear
Just use the same network requests libraries you would use on a normal Android mobile application, like volley, retrofit, okhttp. The code is exactally the same, and by the way, any Android Mobile library works with Android Wear too.
There are lots of post on SO regarding setting up AP (Hotspot) on android mobile. However, in all these cases, the AP is a conduit to the outside internet world. In my case, I just want a server application running over a mobile setup as an AP. And let all the client android mobiles connect to it, send their data and disconnect if they like. No internet connection is assumed (i.e, no gprs/3g etc).
My observations: If I setup a wifi AP (via settings -> tethering and portable hotspots) when it is also connected to GPRS, then another android phone can successfully connect to this AP and send the data to the application. However, if I disable the GPRS, even though the client shows that it is connected to the AP, it can't seem to send any data. It seems that an external internet connection is a necessity for the AP mode to work.
Is this understanding correct? Or am I setting something wrong?
I know that I am late to the party (more than 3 years late :) but I was searching for a solution to this problem and stumbled upon an easy workaround. I am using a Nexus 4 with Android 5.0.1 and I can easily configure my phone to use it as an Android Wi-fi AP hotspot - without internet. Just go to Settings / Data Usage and disable "Mobile data" option under the Mobile tab. Then enable the WiFi hotspot option as usual.
I was trying to get this working in order to play with a VirtualBox machine from VulnHub.com that asked for a Bridged Connection when I was commuting to work (no Internet, but with my laptop and my mobile phone I was able to make it :)
I think you have used the internet IPs in your code not the local IPs for communications,is'nt it?
I have the same use case and was looking for the same info as you are. I checked that some of the WiFi-only tablets do not even have a HotSpot setting. Even the devices that do have it, if I remove the SIM card, I cannot enable the HotSpot (I get a message asking me to insert a SIM first).
It looks like our use case is not supported by Android. Rather, the HotSpot feature was not designed with our use-case in mind. I mean, why would an end-user want to use an Android phone or tablet in a HotSpot mode if it didn't also provide outside connectivity?
I want to start a local network connection using the built-in Wi-Fi hotspot on Android devices.
Is there a way to accomplish it?
And how to communicate between two devices?
EDIT:
I want to do it programmatically. Then I can transfer my own data between devices.
I haven't done this before, so my answer is all theoretical.
I think what you need to do is declare one device the server and start its hotspot manually with a known name.
Start / stop built-in Wi-Fi / USB tethering from code? (According to this question, you can't start hotspot programatically).
Once you have the hotspot set up, you start up the server app and wait for incoming connections. The server app can show you the ip address or hostname.
On the clients, you can do a simple check and see if the hotspot name is around and automatically connect to it if you find it. See this link for connecting to a network:
Using WifiManager to connect to a network
As for your second question, how to communicate - you need to establish a connection between the devices. For this, you need the ip address of the server. The simplest thing to do would be to show the ip address on the server UI and then manually enter it on the clients and press connect. It would then establish a connection to the server on a known port and you can send messages between client and server.
For reference, I found NanoHttpd, which is a webserver for Android. It uses ServerSocket to listen for incoming connections.
Possible answers:
Before ICS and non rooted devices
There is no way you can connect to a device over wifi. There is no API to do. Bluetooth is your best option or user interaction.
Before ICS and rooted devices
I am not sure if someone hacked the code, but when I tried to do an automatic connection to a wifi spot I noticed:
The api is hidden inside the SDK.
The method that does the connection checks the thread who ask for it. If it's not the os thread, it throws an exception.
Using ICS
With ICS there is a new way to connect devices through wifi called Wi-Fi Direct.
Here is a link with some demos.
If you are going to develop your own application for each and every individual terminals(devices) then i think for you socket programming will do the trick .
Yes , android supports socket programming in the same was as java socket programming .
1st google java socket programming tutorials and then you can using the same knowledge in android .
Also do remember to include the uses internet permission in the manifest , actually thats something which ate my brains for a long time :)
You mean communication between wifi enabled devices without any server like p2p? if so its wifi direct which is supported in ICS check this out http://developer.android.com/reference/android/net/wifi/p2p/package-summary.html
Before ICS there is no standard android API for wifi direct, though Galaxy S2 has wifi direct it uses proprietary API's which 3rd party devs can't use.
i dont know programmically create wify LAN,but you can create wify LAN manually,then you can do java tcp/udp program as said by brianestey
"As for your second question, how to communicate - you need to establish a connection between the devices. For this, you need the ip address of the server. The simplest thing to do would be to show the ip address on the server UI and then manually enter it on the clients and press connect. It would then establish a connection to the server on a known port and you can send messages between client and server."
for manual connection follow the steps
take settings/wireless&networks/portable wi-fi hotspot settings from any one of the phone
create new hotspot and turn on wi-fi portable hotspot from there
connect all other device to that hotspot including your pc
you will get ip of each device programmically (includig pc,but i dont know)
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.