com.baidu.location.LocationClient Java Examples
The following examples show how to use
com.baidu.location.LocationClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteBaiduBusActivity.java From BmapLite with Apache License 2.0 | 6 votes |
public void initLocationSDK() { // 定位初始化 mLocClient = new LocationClient(this); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); isFirstLoc = false; }
Example #2
Source File: MainActivity.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //初始化地图控件 mapView = (MapView) findViewById(R.id.mapview); mBaiduMap = mapView.getMap(); //初始化定位 mLocationClient = new LocationClient(getApplicationContext()); //初始化定位 initLocation(); //注册监听函数 mLocationClient.registerLocationListener(this); //开始定位,定位完成后,不管是否成功,都会调用上面的监听函数中的方法 mLocationClient.start(); //设置地图的点击事件 setMapListenter(); }
Example #3
Source File: GeolocationModule.java From react-native-baidu-map with MIT License | 6 votes |
private void initLocationClient(String coorType) { if(context.getCurrentActivity() != null) { AppUtils.checkPermission(context.getCurrentActivity(), Manifest.permission.ACCESS_FINE_LOCATION); } LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationMode.Hight_Accuracy); option.setCoorType(coorType); option.setIsNeedAddress(true); option.setIsNeedAltitude(true); option.setIsNeedLocationDescribe(true); option.setOpenGps(true); locationClient = new LocationClient(context.getApplicationContext()); locationClient.setLocOption(option); Log.i("locationClient", "locationClient"); locationClient.registerLocationListener(this); }
Example #4
Source File: SocialPublishActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
@Override protected void onCreate(Bundle arg0) { setContentView(R.layout.activity_social_publish); super.onCreate(arg0); imagePath = this.getIntent().getStringExtra("imagePath"); Log.e("imagePath---->>>>.", imagePath); if (TextUtils.isEmpty(imagePath)) { finish(); return; } Uri uri_temp = Uri.fromFile(new File(imagePath)); // 第一张图片要特别注意一下,是传过来的.... getTwoImage(uri_temp, true); lists.add(uri_temp); initView(); // 位置相关 mLocationClient = new LocationClient(this); // 声明LocationClient类 mLocationClient.registerLocationListener(myListener); // 注册监听函数 }
Example #5
Source File: LocationUtil.java From AndroidDemo with MIT License | 6 votes |
public LocationUtil(Context context) { locationClient = new LocationClient(context); locationClient.setLocOption(getOption()); locationClient.registerLocationListener(locationListener = new LocationListener() { @Override public void onReceiveLocation(BDLocation bdLocation) { if (bdListener != null) { locationClient.stop(); bdListener.onReceiveLocation(bdLocation); } } @Override public void onLocDiagnosticMessage(int i, int i1, String s) { if (bdListener != null) { bdListener.onFail(i, s); } } }); }
Example #6
Source File: LocationActivity.java From imsdk-android with MIT License | 6 votes |
private void initLocationClient() { geoCoder = GeoCoder.newInstance(); poiSearch = PoiSearch.newInstance(); poiSearch.setOnGetPoiSearchResultListener(this); locationClient = new LocationClient(getApplication()); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType(CoordinateType.BD09LL); // option.setScanSpan(5000);// option.setIsNeedAddress(true); option.setOpenGps(true); option.setLocationNotify(true); option.setIsNeedLocationDescribe(true); option.setIsNeedLocationPoiList(true); option.setIgnoreKillProcess(true); option.SetIgnoreCacheException(true); option.setEnableSimulateGps(true); locationClient.setLocOption(option); locationClient.registerLocationListener(this); locationClient.start(); }
Example #7
Source File: ShareLocationActivity.java From imsdk-android with MIT License | 6 votes |
private void initLocationClient() { locationClient = new LocationClient(getApplicationContext()); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType(CoordinateType.BD09LL); option.setIsNeedAddress(true); option.setOpenGps(true); option.setLocationNotify(true); option.setNeedDeviceDirect(true); option.setIsNeedLocationDescribe(false); option.setIsNeedLocationPoiList(true); option.setIgnoreKillProcess(true); option.SetIgnoreCacheException(true); option.setEnableSimulateGps(true); //5s发送一次自己的位置 option.setScanSpan(5000); locationClient.setLocOption(option); locationClient.registerLocationListener(this); locationClient.start(); }
Example #8
Source File: BaiduMapSelectPoiFragment.java From BmapLite with Apache License 2.0 | 6 votes |
public void initBaiduSdk() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); }
Example #9
Source File: BaiduMapRouteFragment.java From BmapLite with Apache License 2.0 | 6 votes |
public void initLocationSDK() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); isFirstLoc = false; }
Example #10
Source File: IndexDelegate.java From FastWaiMai with MIT License | 6 votes |
private void initLocation() { // 声明LocationClient类 mLocationClient = new LocationClient(getContext()); option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("bd09ll"); option.setOpenGps(true); option.setLocationNotify(true); option.setIgnoreKillProcess(true); option.SetIgnoreCacheException(false); option.setEnableSimulateGps(false); option.setIsNeedLocationDescribe(true); option.setIsNeedLocationPoiList(true); option.setIsNeedAddress(true); mLocationClient.setLocOption(option); // 注册监听函数 mLocationClient.registerLocationListener(myListener); mLocationClient.start(); }
Example #11
Source File: RouteDetailActivity.java From Mobike with Apache License 2.0 | 6 votes |
private void initMap() { mlocationClient = new LocationClient(this); // mlistener = new MylocationListener(); // mlocationClient.registerLocationListener(mlistener); LocationClientOption mOption = new LocationClientOption(); //设置坐标类型 mOption.setCoorType("bd09ll"); //设置是否需要地址信息,默认为无地址 mOption.setIsNeedAddress(true); //设置是否打开gps进行定位 mOption.setOpenGps(true); //设置扫描间隔,单位是毫秒 当<1000(1s)时,定时定位无效 int span = 10000; mOption.setScanSpan(span); //设置 LocationClientOption mlocationClient.setLocOption(mOption); if (!mlocationClient.isStarted()) { mlocationClient.start(); } UiSettings settings = routeBaiduMap.getUiSettings(); settings.setScrollGesturesEnabled(true); }
Example #12
Source File: RouteBaiduBusActivity.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void initLocationSDK() { // 定位初始化 mLocClient = new LocationClient(this); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); isFirstLoc = false; }
Example #13
Source File: BaiduMapSelectPoiFragment.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void initBaiduSdk() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); }
Example #14
Source File: BaiduMapRouteFragment.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void initLocationSDK() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); isFirstLoc = false; }
Example #15
Source File: MapActivity.java From BaiduMap-TrafficAssistant with MIT License | 5 votes |
private void initLocation() { mLocationMode = LocationMode.NORMAL; mLocationClient = new LocationClient(this); mLocationListener = new MyLocationListener(); mLocationClient.registerLocationListener(mLocationListener); LocationClientOption option = new LocationClientOption(); option.setCoorType("bd09ll"); option.setIsNeedAddress(true); option.setOpenGps(true); option.setScanSpan(1000);// 设置定位一秒钟请求一次; mLocationClient.setLocOption(option); // 初始化图标 mIconLocation = BitmapDescriptorFactory .fromResource(R.drawable.navi_map_gps_locked); myOrientationListener = new MyOrientationListener(context); myOrientationListener .setOnOrientationListener(new OnOrientationListener() { @Override public void onOrientationChanged(float x) { mCurrentX = x; } }); }
Example #16
Source File: GpsUtil.java From MyWeather with Apache License 2.0 | 5 votes |
/** * 初始化 */ public GpsUtil(Context ctx, BDLocationListener locationListener) { context = ctx; try { mLocationClient = new LocationClient(context.getApplicationContext()); mLocationClient.registerLocationListener(locationListener); //注册监听函数 initLocation(); mLocationClient.start(); } catch (Exception e) { Log.e("GpsUtil error : ", e.getMessage(), e); } }
Example #17
Source File: BaiduMapActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
private void showMapWithLocationClient() { progressDialog = new ProgressDialog(this); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage("正在确定你的位置..."); progressDialog.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface arg0) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } Log.d("map", "cancel retrieve location"); finish(); } }); progressDialog.show(); mLocClient = new LocationClient(this); mLocClient.registerLocationListener(myListener); LocationClientOption option = new LocationClientOption(); option.setOpenGps(true);// 打开gps // option.setCoorType("bd09ll"); //设置坐标类型 // Johnson change to use gcj02 coordination. chinese national standard // so need to conver to bd09 everytime when draw on baidu map option.setCoorType("gcj02"); option.setScanSpan(30000); option.setAddrType("all"); mLocClient.setLocOption(option); }
Example #18
Source File: HomeActivity.java From LoveTalkClient with Apache License 2.0 | 5 votes |
private void initBaiduLocClient() { mLocClient = new LocationClient(this.getApplicationContext()); mLocClient.setDebug(true); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setScanSpan(5000); option.setIsNeedAddress(false); option.setCoorType("bd09ll"); option.setIsNeedAddress(true); mLocClient.setLocOption(option); mLocationListener = new MyLocationListener(); mLocClient.registerLocationListener(mLocationListener); mLocClient.start(); }
Example #19
Source File: MainActivity.java From nearbydemo with Eclipse Public License 1.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { boolean first = getSharedPreferences("userinfo", Context.MODE_PRIVATE).getBoolean("first", false); if (!first) { Intent intent = new Intent(this, LoginActivity.class); startActivity(intent); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); reqQueue = Volley.newRequestQueue(this); imageLoader = new ImageLoader(reqQueue, new BitmapLruCache()); //百度地图定位 mLocationClient = new LocationClient(getApplicationContext());//是否有问题?? mMyLocationListener = new MyLocationListener(); mLocationClient.registerLocationListener(mMyLocationListener); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationMode.Hight_Accuracy);// 设置定位模式 option.setCoorType("bd09ll");// 返回的定位结果是百度经纬度,默认值gcj02 option.setIsNeedAddress(true);// 返回的定位结果包含地址信息 option.setNeedDeviceDirect(true);// 返回的定位结果包含手机机头的方向 mLocationClient.setLocOption(option); }
Example #20
Source File: LocationUtils.java From SmartOrnament with Apache License 2.0 | 5 votes |
public LocationUtils(Context context){ prefs = context.getSharedPreferences("Location_data", MODE_PRIVATE);//这玩意不能放在定义全局变量时初始化,否则没用 editor=prefs.edit(); this.context=context; mLocationClient=new LocationClient(context); initLocation();//给mLocationClient设置定位的各种参数 }
Example #21
Source File: ZApplication.java From nearbydemo with Eclipse Public License 1.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); Log.i(TAG, "����ZApplication��onCreate����"); mLocationClient = new LocationClient(this); mMyLocationListener = new MyLocationListener(); mLocationClient.registerLocationListener(mMyLocationListener); mGeofenceClient = new GeofenceClient(this); mNotifyLister = new NotifyLister(); mVibrator =(Vibrator)getApplicationContext().getSystemService(Service.VIBRATOR_SERVICE); }
Example #22
Source File: LocationUtils.java From WayHoo with Apache License 2.0 | 5 votes |
public LocationUtils(Context context, LocationListener listener) { if (listener == null) new NullPointerException("LocationListener can't be null"); mListener = listener; mLocationClient = new LocationClient(context, getLocationClientOption(context)); mLocationClient.registerLocationListener(mLocationListener); }
Example #23
Source File: LocationActivity.java From Conquer with Apache License 2.0 | 5 votes |
private void initLocClient() { // 开启定位图层 mBaiduMap.setMyLocationEnabled(true); mBaiduMap.setMyLocationConfigeration(new MyLocationConfigeration(MyLocationConfigeration.LocationMode.NORMAL, true, null)); // 定位初始化 mLocClient = new LocationClient(this); mLocClient.registerLocationListener(myListener); LocationClientOption option = new LocationClientOption(); option.setProdName("bmobim");// 设置产品线 option.setOpenGps(true);// 打开gps option.setCoorType("bd09ll"); // 设置坐标类型 option.setScanSpan(1000); option.setOpenGps(true); option.setIsNeedAddress(true); option.setIgnoreKillProcess(true); mLocClient.setLocOption(option); mLocClient.start(); if (mLocClient != null && mLocClient.isStarted()) mLocClient.requestLocation(); if (lastLocation != null) { // 显示在地图上 LatLng ll = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); } }
Example #24
Source File: LocationFragment.java From foodie-app with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); restaurantListView.setLayoutManager(new LinearLayoutManager(restaurantListView.getContext())); //定位 //定位核心类 mLocationClient = new LocationClient(getActivity().getApplicationContext()); //声明LocationClient类 mLocationClient.registerLocationListener(myListener); //注册监听函数 initLocation();//初始化 mLocationClient.start(); //更新列表 updateRestaurantInfo(); sr.setColorSchemeResources( R.color.colorPrimary, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); sr.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { updateRestaurantInfo(); sr.setRefreshing(false); } }); }
Example #25
Source File: WelcomeActivity.java From CoolWeather with Apache License 2.0 | 5 votes |
private void initBaiduMapLocation() { mLocationClient = new LocationClient(this.getApplicationContext()); mListener = new MyLocationListener(); mLocationClient.registerLocationListener(mListener);// 娉ㄥ唽鐩戝惉鍑芥暟 LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationMode.Hight_Accuracy); option.setIsNeedAddress(true); mLocationClient.setLocOption(option); mLocationClient.start(); }
Example #26
Source File: BaiduLocationService.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void requestLocation(Context context, @NonNull LocationCallback callback){ this.callback = callback; LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Battery_Saving); // 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 option.setCoorType("wgs84"); // 可选,默认gcj02,设置返回的定位结果坐标系 option.setScanSpan(0); // 可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的 option.setIsNeedAddress(true); // 可选,设置是否需要地址信息,默认不需要 option.setOpenGps(false); // 可选,默认false,设置是否使用gps option.setLocationNotify(false); // 可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果 option.setIsNeedLocationDescribe(false); // 可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近” option.setIsNeedLocationPoiList(false); // 可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到 option.setIgnoreKillProcess(false); // 可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死 option.SetIgnoreCacheException(true); // 可选,默认false,设置是否收集CRASH信息,默认收集 option.setEnableSimulateGps(false); // 可选,默认false,设置是否需要过滤gps仿真结果,默认需要 option.setWifiCacheTimeOut(5 * 60 * 1000); // 可选,如果设置了该接口,首次启动定位时,会先判断当前WiFi是否超出有效期,若超出有效期,会先重新扫描WiFi,然后定位 client = new LocationClient(context.getApplicationContext()); client.setLocOption(option); client.registerLocationListener(listener); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { manager.createNotificationChannel(getLocationNotificationChannel(context)); client.enableLocInForeground( GeometricWeather.NOTIFICATION_ID_LOCATION, getLocationNotification(context)); } client.start(); }
Example #27
Source File: InviteBll.java From PlayTogether with Apache License 2.0 | 5 votes |
/** * 获得发邀请人的地址 * * @param context * @return */ public Observable<AVGeoPoint> getLocation(final Context context) { return Observable.create(new Observable.OnSubscribe<AVGeoPoint>() { @Override public void call(final Subscriber<? super AVGeoPoint> subscriber) { LocationClient client = LocationUtils.getLocationClient(context); client.registerLocationListener(new BDLocationListener() { @Override public void onReceiveLocation(BDLocation location) { if (location.getLocType() == BDLocation.TypeGpsLocation || location .getLocType() == BDLocation.TypeNetWorkLocation || location .getLocType() == BDLocation.TypeOffLineLocation) { subscriber.onNext(new AVGeoPoint(location.getLatitude(), location .getLongitude())); } else { subscriber.onNext(null); } LocationUtils.stopClient(); } }); client.start(); } }); }
Example #28
Source File: TrackerService.java From LocationProvider with Apache License 2.0 | 5 votes |
/** * 注册百度地图定位功能 */ private void initLocationClient() { client = new LocationClient(this); client.setLocOption(getDefaultLocationClientOption()); client.registerLocationListener(mLocationListener); start(); }
Example #29
Source File: MainActivity.java From Mobike with Apache License 2.0 | 5 votes |
private void initMap() { baiduMap = mBaiduMap.getMap(); baiduMap.setMyLocationEnabled(true); mlocationClient = new LocationClient(getApplicationContext()); mlocationClient.registerLocationListener(new MylocationListener()); // mBaiduMap.showScaleControl(false);// 隐藏比例尺控件 mBaiduMap.showZoomControls(false);//隐藏缩放按钮 LocationClientOption option = new LocationClientOption(); option.setOpenGps(true); // 打开gps option.setCoorType("bd09ll"); // 设置坐标类型 option.setScanSpan(5000);//设置onReceiveLocation()获取位置的频率 option.setIsNeedAddress(true);//如想获得具体位置就需要设置为true mlocationClient.setLocOption(option); mlocationClient.start(); mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING; baiduMap.setMyLocationConfigeration(new MyLocationConfiguration( mCurrentMode, true, null)); myOrientationListener = new MyOrientationListener(this); //通过接口回调来实现实时方向的改变 myOrientationListener.setOnOrientationListener(new MyOrientationListener.OnOrientationListener() { @Override public void onOrientationChanged(float x) { mCurrentX = x; } }); myOrientationListener.start(); mSearch = RoutePlanSearch.newInstance(); mSearch.setOnGetRoutePlanResultListener(this); initMarkerClickEvent(); }
Example #30
Source File: BaiduMapFragment.java From BmapLite with GNU General Public License v3.0 | 5 votes |
public void initLocationSdk() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); try { LocationManager locManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { onMessage(getResources().getString(R.string.gps_enabled_false)); } } catch (Exception e) { e.printStackTrace(); } }