简体   繁体   中英

Android HotSpot Listening Socket

My app opens an http socket to accept some 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM