定位功能是否可用由定位服务和定位权限共同决定:
判断定位服务:
/**
* @author:程龙 date; On 2018/8/13
*/
/**
* 手机是否开启位置服务,如果没有开启那么所有app将不能使用定位功能
*/
public static boolean isLocServiceEnable(Context context) {
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (gps || network) {
return true;
}
return false;
}
判断定位权限:
/**
* 检查权限列表
*
* @param conte