Android 获取经纬度
来源:互联网 发布:模拟经营单机 知乎 编辑:程序博客网 时间:2024/04/30 09:23
@TargetApi(Build.VERSION_CODES.KITKAT)@SuppressWarnings("deprecation")public static boolean isGpsEnabled(Context context) { if (PackageUtil.checkPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)) { LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); return lm.isProviderEnabled(LocationManager.GPS_PROVIDER); } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { String providers = Secure.getString(context.getContentResolver(), Secure.LOCATION_PROVIDERS_ALLOWED); if (TextUtils.isEmpty(providers)) { return false; } return providers.contains(LocationManager.GPS_PROVIDER); } else { final int locationMode; try { locationMode = Secure.getInt(context.getContentResolver(), Secure.LOCATION_MODE); } catch (SettingNotFoundException e) { e.printStackTrace(); return false; } switch (locationMode) { case Secure.LOCATION_MODE_BATTERY_SAVING: case Secure.LOCATION_MODE_HIGH_ACCURACY: case Secure.LOCATION_MODE_SENSORS_ONLY: return true; case Secure.LOCATION_MODE_OFF: default: return false; } }}
解决android4.4 的问题
0 0
- Android 如何获取经纬度
- Android获取手机经纬度
- Android 获取经纬度
- Android获取GPS经纬度
- Android 如何获取经纬度
- Android 如何获取经纬度
- Android获取手机经纬度
- Android获取经纬度
- Android 获取经纬度
- Android 如何获取经纬度
- android 获取经纬度
- Android获取经纬度
- Android 的经纬度获取
- Android获取经纬度
- Android 获取手机经纬度
- Android根据地址获取经纬度,根据经纬度
- Android GPS定位 获取经纬度
- Android根据经纬度获取地址
- Ext动态删除items方法参考
- HTML自学笔记(四)
- 关于xmlns:tools和android:onClick使用
- HTTP POST GET 本质区别详解
- CCNode
- Android 获取经纬度
- android关于AndroidManifest.xml详细分析
- R xts
- 设计模式(2)-对象创建型模式-Factory Method模式
- 最新Android面试题整理 5月
- 当杨辰骑着小自行车来到村口靠近了镇上国道马路的地方,看见杨蓝蓝正在一个游戏房里跳来跳去的欢喜样,不禁再度感慨,自己被未来那时代荼毒了有点深,一听到打飞机就想歪。
- 从“零容忍”看当前“打虎”之新气象
- JS实现日期相加减
- Windows系统服务编程