|
|
|
|
@ -32,6 +32,7 @@ import com.rehome.bhdxj.base.BaseActivity3;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class BlueTestInfoActivity extends BaseActivity3 {
|
|
|
|
|
@ -92,7 +93,9 @@ public class BlueTestInfoActivity extends BaseActivity3 {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setAdapter();
|
|
|
|
|
registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
|
|
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Intent gattServiceIntent = new Intent(BlueTestInfoActivity.this, BluetoothLeService.class);
|
|
|
|
|
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
|
|
|
|
|
initconn = true;
|
|
|
|
|
@ -241,7 +244,7 @@ public class BlueTestInfoActivity extends BaseActivity3 {
|
|
|
|
|
if (initconn) {
|
|
|
|
|
if (!mConnected) mBluetoothLeService.connect(mDeviceAddress);
|
|
|
|
|
} else {
|
|
|
|
|
registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
|
|
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
|
|
|
|
|
Intent gattServiceIntent = new Intent(BlueTestInfoActivity.this, BluetoothLeService.class);
|
|
|
|
|
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
|
|
|
|
|
initconn = true;
|
|
|
|
|
@ -396,7 +399,8 @@ public class BlueTestInfoActivity extends BaseActivity3 {
|
|
|
|
|
scanLeDevice(false);
|
|
|
|
|
mLeDeviceListAdapter.clear();
|
|
|
|
|
unbindService(mServiceConnection);
|
|
|
|
|
unregisterReceiver(mGattUpdateReceiver);
|
|
|
|
|
// 注销广播接收器
|
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(mGattUpdateReceiver);
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|