| | |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Bundle; |
| | | import android.os.IBinder; |
| | | import android.os.Message; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.ActivityCompat; |
| | |
| | | MainApp.theApp.bleManager.closeBluetoothGatt(); |
| | | } |
| | | mBluetoothService.connectDevice(scanResultList.get(position)); |
| | | EventMessage eventMessage = new EventMessage(); |
| | | eventMessage.setType(AppConfig.BLUETOOCH_CHANGE_CONNECT); |
| | | EventBus.getDefault().post(eventMessage); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | protected void initListener() { |
| | | iv_search.setOnClickListener(this); |
| | | // iv_search.setOnClickListener(this); |
| | | iv_searchpic.setOnClickListener(this); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | protected void processClick(View view) { |
| | | switch (view.getId()) { |
| | | case R.id.iv_search: |
| | | case R.id.iv_searchpic: |
| | | mBluetoothService.openBlueTooth(); |
| | | if (isScan) { |
| | | if (mBluetoothService != null) { |
| | | mBluetoothService.cancelScan(); |
| | |
| | | |
| | | @Override |
| | | public void onServiceDisconnected(ComponentName name) { |
| | | mBluetoothService = null; |
| | | if (mBluetoothService != null) { |
| | | mBluetoothService.cancelScan(); |
| | | mBluetoothService.closeConnect(); |
| | | mBluetoothService = null; |
| | | } |
| | | } |
| | | }; |
| | | |
| | |
| | | if (ActivityManager.getActivityManager().isActivityExist(BLESearchActivity.this.getClass().getName())) { |
| | | progressDialog.dismiss(); |
| | | } |
| | | Log.d("chonglian","孕妇哨连接断开"); |
| | | Log.d("chonglian", "孕妇哨连接断开"); |
| | | mToatUtils.showSingletonToast("孕妇哨连接断开"); |
| | | EventMessage msg = new EventMessage(); |
| | | msg.setType(AppConfig.GET_BLE_DISCONNECT); |
| | |
| | | |
| | | @Override |
| | | public void onServicesDiscovered() { |
| | | Log.d("chonglian","孕妇哨连接成功"); |
| | | Log.d("chonglian", "孕妇哨连接成功"); |
| | | EventMessage msg = new EventMessage(); |
| | | msg.setType(AppConfig.GET_BLE_SERVICE); |
| | | EventBus.getDefault().postSticky(msg); |
| | |
| | | progressDialog.dismiss(); |
| | | finish(); |
| | | } |
| | | |
| | | } |
| | | }; |
| | | |