判断GPS定位服务是否打开

来源:互联网 发布:mac 视频播放器推荐 编辑:程序博客网 时间:2024/05/21 14:42
/**
* Gps是否打开
* 需要<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />权限
*
* @param context the context
* @return true, if is gps enabled
*/
public static boolean isGpsEnabled(Context context) {
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);  
   return lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
0 0