My app opens an http socket to accept s开发者_如何学Pythonome files from user's browser, so it needs WiFi ON for that. What I think would be cool if the app could continue doing that in WiFi HotSpot mode (tethering?) however I can't obtain the Android's IP address to start listening on. Is it possible at all?
I was doing similar task. When enabling HotSpot and you ask Android what's your IP, you'll get the IP address given from 3G network (if you are getting IP address with this code, it seems the last network interface interrogated is 3G, and this is the value returned by the function).
That IP address from 3G interface will work anyways: your Wifi client will connect to your device because Android is acting as a "bridge" (from Wifi to 3G) and the 3G-interface will be visible from your Wifi client.
精彩评论