如何根据位置对象获取用户的国家?

huangapple 未分类评论46阅读模式
英文:

Ho to get user´s country based on Location object?

问题

我需要用户的位置信息来支持我的应用程序的某些功能,并且还希望将其传递给 Admob 请求以获取定向广告。我已成功获取了纬度和经度,但我不知道如何利用这些信息来确定用户所在的国家。我们是否有办法实现类似这样的功能?

Location country = 12.8654, 85.2072 //尼加拉瓜
Location userLocation = getCurrentLocation();

if (country.contains(userLocation){...}
英文:

I need the user´s location for some features of my app and also want to pass it on to Admob requests to get targeted ads. I´m successfully getting the latitude and longitude however I don´t know how to use that to determine in which country the user is. Is there any way how we can do something like this?

Location country = 12.8654, 85.2072 //Nicaragua
Location userLocation = getCurrentLocation();

if (country.contains(userLocation){...}

huangapple
  • 本文由 发表于 2020年4月6日 04:20:22
  • 转载请务必保留本文链接:https://java.coder-hub.com/61048962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定