| | |
| | | private int index = 0; |
| | | private boolean islogin = false; |
| | | |
| | | private BluetoothService mBluetoothService; |
| | | public static BluetoothService mBluetoothService; |
| | | |
| | | @Override |
| | | protected void getBundleExtras(Bundle extras) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | protected void onStart() { |
| | | super.onStart(); |
| | | bindService(); |
| | | PermissionUtil.verifyStoragePermissions(this); |
| | | } |
| | | |
| | | @Override |
| | | protected void onStop() { |
| | | super.onStop(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | mBluetoothService = ((BluetoothService.BluetoothBinder) service).getService(); |
| | | mBluetoothService.setScanCallback(callback); |
| | | String mac = MainApp.theApp.sharedPreferencesUtil.getBLE(); |
| | | System.out.println("BleGattCallback init"); |
| | | if (!TextUtils.isEmpty(mac)) { |
| | | mBluetoothService.scanAndConnect5(mac); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onServiceDisconnected(ComponentName name) { |
| | | System.out.println("BleGattCallback onServiceDisconnected"); |
| | | mBluetoothService = null; |
| | | } |
| | | }; |
| | |
| | | private BluetoothService.Callback callback = new BluetoothService.Callback() { |
| | | @Override |
| | | public void onStartScan() { |
| | | |
| | | System.out.println("MainActivity onStartScan"); |
| | | } |
| | | |
| | | @Override |
| | | public void onScanning(ScanResult result) { |
| | | |
| | | System.out.println("MainActivity onScanning"); |
| | | } |
| | | |
| | | @Override |
| | | public void onScanComplete() { |
| | | |
| | | System.out.println("MainActivity onScanComplete"); |
| | | } |
| | | |
| | | @Override |
| | | public void onConnecting() { |
| | | System.out.println("MainActivity onConnecting"); |
| | | progressDialog.setTitleText("正在连接..."); |
| | | progressDialog.show(); |
| | | } |
| | | |
| | | @Override |
| | | public void onConnectFail() { |
| | | System.out.println("MainActivity onConnectFail"); |
| | | progressDialog.dismiss(); |
| | | mToatUtils.showSingletonToast("连接失败"); |
| | | mBluetoothService.closeConnect(); |
| | | EventMessage msg = new EventMessage(); |
| | | msg.setType(AppConfig.GET_BLE_DISCONNECT); |
| | | EventBus.getDefault().postSticky(msg); |
| | |
| | | |
| | | @Override |
| | | public void onDisConnected() { |
| | | System.out.println("MainActivity onDisConnected"); |
| | | progressDialog.dismiss(); |
| | | mToatUtils.showSingletonToast("孕妇哨连接断开"); |
| | | EventMessage msg = new EventMessage(); |
| | |
| | | |
| | | @Override |
| | | public void onServicesDiscovered() { |
| | | System.out.println("MainActivity onServicesDiscovered"); |
| | | progressDialog.dismiss(); |
| | | EventMessage msg = new EventMessage(); |
| | | msg.setType(AppConfig.GET_BLE_SERVICE); |