public class BaseActivity extends Activity { private static boolean gpsFlag; private Vibrator mVibrator01 = null; private static LocationClient mLocClient; private LocationManager alm; mLocClient = ((GetLocation) getApplication()).mLocationClient; mVibrator01 = (Vibrator) getApplication().getSystemService( Service.VIBRATOR_SERVICE); ((GetLocation) getApplication()).mVibrator01 = mVibrator01; alm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); gpsFlag = alm .isProviderEnabled(android.location.LocationManager.GPS_PROVIDER); getData(); } private static void getData() { setLocationOption(); mLocClient.start(); if (mLocClient != null && mLocClient.isStarted()) { // setLocationOption(); mLocClient.requestLocation(); } else Log.d("boot", "locClient is null or not started"); } // 设置相关参数 private static void setLocationOption() { LocationClientOption option = new LocationClientOption(); option.setOpenGps(gpsFlag); // 打开gps option.setCoorType("bd09ll"); // 设置坐标类型 option.setAddrType("all"); // 设置地址信息,仅设置为“all”时有地址信息,默认无地址信息 // option.setScanSpan(10000); // 设置定位模式,小于1秒则一次定位;大于等于1秒则定时定位 mLocClient.setLocOption(option); }
Android 百度 基站定位
猜你喜欢
转载自yebingzi.iteye.com/blog/1779276
今日推荐
周排行