|
|
|
|
@ -84,7 +84,7 @@ public class MainActivity extends BaseActivity3 {
|
|
|
|
|
//private int[] imageId = {R.mipmap.icon6, R.mipmap.icon11, R.mipmap.icon_dxj, R.mipmap.icon13};
|
|
|
|
|
//private int[] colors = {R.drawable.radius_e3, R.drawable.radius_a4, R.drawable.radius_a1, R.drawable.radius_b1};
|
|
|
|
|
private long exitTime = 0;
|
|
|
|
|
private BluetoothLeService mBluetoothLeService;
|
|
|
|
|
//private BluetoothLeService mBluetoothLeService;
|
|
|
|
|
public static final int REQUEST_CHECK_TEMPERATURE = 1;
|
|
|
|
|
public static final int REQUEST_CHECK_VIBRATION = 2;
|
|
|
|
|
private String userID;
|
|
|
|
|
@ -284,8 +284,8 @@ public class MainActivity extends BaseActivity3 {
|
|
|
|
|
colors.add(R.drawable.radius_c6);
|
|
|
|
|
|
|
|
|
|
setAdapter();
|
|
|
|
|
Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
|
|
|
|
|
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
|
|
|
|
|
// Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
|
|
|
|
|
// bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
|
|
|
|
|
String username = (String) SPUtils.get(MainActivity.this, Contans.USERNAME, String.valueOf(""));
|
|
|
|
|
if (username != null) {
|
|
|
|
|
tvLoginUser.setText("登录用户:" + username);
|
|
|
|
|
@ -432,17 +432,17 @@ public class MainActivity extends BaseActivity3 {
|
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onServiceConnected(ComponentName componentName, IBinder service) {
|
|
|
|
|
mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onServiceDisconnected(ComponentName componentName) {
|
|
|
|
|
mBluetoothLeService = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onServiceConnected(ComponentName componentName, IBinder service) {
|
|
|
|
|
// mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onServiceDisconnected(ComponentName componentName) {
|
|
|
|
|
// mBluetoothLeService = null;
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
|
|
@ -578,7 +578,6 @@ public class MainActivity extends BaseActivity3 {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -609,11 +608,6 @@ public class MainActivity extends BaseActivity3 {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
if(mBluetoothLeService!=null){
|
|
|
|
|
mBluetoothLeService.disconnect();
|
|
|
|
|
mBluetoothLeService.close();
|
|
|
|
|
}
|
|
|
|
|
unbindService(mServiceConnection);
|
|
|
|
|
if(flashUtil!=null){
|
|
|
|
|
flashUtil.finishFlashUtils();
|
|
|
|
|
}
|
|
|
|
|
@ -624,8 +618,6 @@ public class MainActivity extends BaseActivity3 {
|
|
|
|
|
if(timer!=null){
|
|
|
|
|
timer.cancel();
|
|
|
|
|
}
|
|
|
|
|
Intent intent = new Intent(this, BluetoothLeService.class);
|
|
|
|
|
stopService(intent);
|
|
|
|
|
|
|
|
|
|
// 注销广播接收器
|
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(myReceiver);
|
|
|
|
|
|