Get location of wifi ip in android

守給你的承諾、 提交于 2019-11-29 07:31:22

There's lots of online APIs available to determine a location based on an IP address, e.g. here, here, or here.
You could make a request to one of those services, passing in the appropriate "Internet-facing" IP address (which is different than the internal IP address that usually starts with 192.168., see here for an explanation).

if your goal is to get the user's location, use android location services. if your app has requested it and the user hasn't disabled wireless location services, it will use wifi as well cellular networks. it's already packaged right into the SDK and convenient to use.

it might not be a nice thing to go behind the user's back with other methods and get their location without requesting a permission to do so. if you need their location, you might as well go through the approved mechanism.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!