陈奇
2018-11-01 cdbaf79d124d46b69dc62b653fde55f9d40b5534
app/src/main/java/com/moral/yunfushao/activity/BLESearchActivity.java
@@ -8,7 +8,6 @@
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;
@@ -103,10 +102,10 @@
                    /**
                     * 如果连接状态,断开重新连接
                     */
                    if (MainApp.theApp.bleManager != null && MainApp.theApp.bleManager.isConnected()) {
                        mBluetoothService.closeConnect();
                    if (MainApp.theApp.bleManager != null) {
                        MainApp.theApp.bleManager.closeBluetoothGatt();
                    }
                    mBluetoothService.connectDevice(scanResultList.get(position));
                    mBluetoothService.scanAndConnect5(scanResultList.get(position).getDevice().getAddress());
                }
            }
@@ -176,7 +175,11 @@
        @Override
        public void onServiceDisconnected(ComponentName name) {
            mBluetoothService = null;
            if (mBluetoothService != null) {
                mBluetoothService.cancelScan();
                mBluetoothService.closeConnect();
                mBluetoothService = null;
            }
        }
    };
@@ -214,7 +217,7 @@
            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);
@@ -226,7 +229,7 @@
            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);
@@ -235,7 +238,7 @@
        @Override
        public void onServicesDiscovered() {
            Log.d("chonglian","孕妇哨连接成功");
            Log.d("chonglian", "孕妇哨连接成功");
            EventMessage msg = new EventMessage();
            msg.setType(AppConfig.GET_BLE_SERVICE);
            EventBus.getDefault().postSticky(msg);