Blankj / Blankj/AndroidUtilCode

LocationUtils isLocationEnabled能否添加判断LocationManager.PASSIVE_PROVIDER

Open
#1,773 0 comments 0 reactions 1 assignee Claimed by @Blankj View on GitHub
help wanted
Dominant language
Java
Stars
33.6k
Forks
10.6k
PR merge metrics
No merged PRs in 30d

Description

## Describe the feature

在某些杂牌机子上判断是否开启定位,NETWORK_PROVIDER和GPS_PROVIDER都返回false,只有PASSIVE_PROVIDER返回true,实际场景是只是判断是否开启了定位再去获取wifi ssd,不考虑是否能拿到定位,看能不能库里增加一下以便其他人有同样的需求。或者也可以再增加一个isPassiveEnable也得吧。

## Reference

public static boolean isLocationEnabled() {
LocationManager lm = (LocationManager) Utils.getApp().getSystemService(Context.LOCATION_SERVICE);
return lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
|| lm.isProviderEnabled(LocationManager.GPS_PROVIDER)
|| lm.isProviderEnabled(LocationManager.PASSIVE_PROVIDER) ;
}

![image](https://github.com/Blankj/AndroidUtilCode/assets/12773190/d9a572b5-ab08-421b-9f79-6db762c45e37)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.