cd4610db89c393067009359ed68f26be1590edc0.svn-base 1.1 KB

123456789101112131415161718192021222324252627
  1. package eVVM.apk.helper;
  2. import android.app.PendingIntent;
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.location.LocationManager;
  6. import android.net.Uri;
  7. public class GpsUtil {
  8. /**
  9. * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的
  10. * @param context
  11. * @return true 表示开启
  12. */
  13. public static final boolean isOPen(final Context context) {
  14. LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
  15. // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)
  16. boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
  17. // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)
  18. boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
  19. if (gps || network) {
  20. return true;
  21. }
  22. return false;
  23. }
  24. }