| | |
| | | import android.app.Application; |
| | | import android.bluetooth.BluetoothGattService; |
| | | |
| | | import com.baidu.location.BDLocation; |
| | | import com.baidu.location.BDLocationListener; |
| | | import com.baidu.location.LocationClient; |
| | | import com.baidu.location.LocationClientOption; |
| | | import com.baidu.mapapi.SDKInitializer; |
| | | import com.clj.fastble.BleManager; |
| | | import com.lzy.okgo.OkGo; |
| | |
| | | */ |
| | | public BleManager bleManager; |
| | | public BluetoothGattService usrService; |
| | | |
| | | /** |
| | | * 定位相关 |
| | | */ |
| | | LocationClient mLocClient; |
| | | public MyLocationListenner myListener; |
| | | public static double mLat,mLon; |
| | | public static String address; |
| | | @Override |
| | | public void onCreate() { |
| | | super.onCreate(); |
| | |
| | | if(sharedPreferencesUtil == null){ |
| | | sharedPreferencesUtil = new SharedPreferencesUtil(this); |
| | | } |
| | | // userId = sharedPreferencesUtil.getUserid(); |
| | | userId = "1"; |
| | | userId = sharedPreferencesUtil.getUserid(); |
| | | |
| | | bleManager = new BleManager(this); |
| | | |
| | | myListener = new MyLocationListenner(); |
| | | // 定位初始化 |
| | | mLocClient = new LocationClient(this); |
| | | mLocClient.registerLocationListener(myListener); |
| | | LocationClientOption option = new LocationClientOption(); |
| | | option.setOpenGps(true); // 打开gps |
| | | option.setCoorType("bd09ll"); // 设置坐标类型 |
| | | option.setIsNeedAddress(true); |
| | | option.setScanSpan(1000*60); |
| | | mLocClient.setLocOption(option); |
| | | mLocClient.start(); |
| | | } |
| | | |
| | | /** |
| | | * 定位SDK监听函数 |
| | | */ |
| | | public class MyLocationListenner implements BDLocationListener { |
| | | |
| | | @Override |
| | | public void onReceiveLocation(BDLocation location) { |
| | | // map view 销毁后不在处理新接收的位置 |
| | | if (location == null) { |
| | | return; |
| | | } |
| | | mLat = location.getLatitude(); |
| | | mLon = location.getLongitude(); |
| | | address = location.getAddrStr(); |
| | | XLog.d(mLat+"|"+mLon+"|"+address); |
| | | } |
| | | } |
| | | } |