Android:检查是否使用熔合位置提供程序启用位置服务 [英] Android: Check if Location Services Enabled using Fused Location Provider

查看:154
本文介绍了Android:检查是否使用熔合位置提供程序启用位置服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Android文档:


Google位置服务API是Google Play服务的一部分,
提供了更多功能强大的高级框架,自动
处理位置提供者,用户移动和位置准确性,而不是
android.location 中的平台位置API。


但是使用融合位置提供程序(来自Google Play服务中的位置API)我不知道如何检查用户是否拥有位置启用或禁用。



使用 old android.location 很容易:

  locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); 
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

但我不想同时使用Google Play服务融合位置提供商和安卓位置。



如何查看用户是否使用Fused Location Provider启用位置



预先致谢。 SettingsApi :检查您的位置请求,然后确保设备的系统设置已针对应用的位置需求。


According to the Android documentation:

The Google Location Services API, part of Google Play Services, provides a more powerful, high-level framework that automatically handles location providers, user movement, and location accuracy than the platform location API in android.location.

But using the fused location provider (from location APIs in Google Play services) I do not know how to check if the user has the location enabled or disabled.

Using the old android.location it was easy:

locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

But I don´t want to use both Google Play Services fused location provider and old android location.

How could I check if the location is enabled by the user using the Fused Location Provider?

Thanks in advance.

解决方案

See SettingsApi: check your location request then ensure that the device's system settings are properly configured for the app's location needs.

这篇关于Android:检查是否使用熔合位置提供程序启用位置服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆