1 2 3 4 5 6 7 8 9 10 |
public boolean hasGPSDevice(Context context) { final LocationManager mgr = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE); if ( mgr == null ) return false; final List<String> providers = mgr.getAllProviders(); if ( providers == null ) return false; return providers.contains(LocationManager.GPS_PROVIDER); } |
参考:https://blog.csdn.net/wangcan2014/article/details/17913795
获取定位信息的详细代码请参见:https://www.cnblogs.com/powerwu/articles/9228307.html