如何检查wifi位置服务是否开启......?(How to check if wifi location service is on…?)

编程入门 行业动态 更新时间:2024-10-05 09:30:33
如何检查wifi位置服务是否开启......?(How to check if wifi location service is on…?)

我正在使用一个使用用户位置的应用程序。

我可以成功地询问用户wifi和gps启用。 如您所知,您可以使用WiFi,但不能提供您的位置。

问题是我想要让用户启​​用wifi位置获取服务,如果它被禁用。 我使用wifi管理器用于wifi和LOCATION_PROVIDERS_ALLOWED用于GPS。两者都很好用。

//provider variable code String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); //i use the string into an if statement if (!provider.contains("gps")){ }

我知道我可以将启用的提供程序转换为用逗号分隔的变量。 它工作得很好..但是“gps”是GPS的名称,但WiFi的名称是什么?

I am working on an application that uses the location of the user.

I can successfully ask the user for wifi and gps enable. As you know you can have WiFi on but prevent it from providing your location.

The thing is i want to ask the user to enable the wifi location obtain service if it is disabled. I use a wifi manager for wifi and a LOCATION_PROVIDERS_ALLOWED for GPS.And both work great.

//provider variable code String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); //i use the string into an if statement if (!provider.contains("gps")){ }

And i understand that i can get enabled providers into a variable separated with comma. It works great..but "gps" is the name for GPS but what is the name for WiFi into the string???

最满意答案

有两个提供商。 一个是GPS,另一个叫网络,包括Wifi和手机信号塔。

因此,如果两个提供程序都已启用,则您获得的响应是network,gps

There are two providers. One is GPS, the other is called network, and includes Wifi and cell towers.

So if both providers are enabled, the response you get is network,gps

更多推荐

本文发布于:2023-08-07 11:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464109.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   wifi   check   service   location

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!