| | |
| | | import com.moral.yunfushao.ui.PanelView; |
| | | import com.moral.yunfushao.utils.AudioUtils; |
| | | import com.moral.yunfushao.utils.DebugUtils; |
| | | import com.moral.yunfushao.utils.T; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.greenrobot.eventbus.Subscribe; |
| | |
| | | private Runnable reconnectRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | System.out.println("chenqi 立刻重连"); |
| | | //重连 |
| | | if (mBluetoothService == null) { |
| | | return; |
| | |
| | | } |
| | | }); |
| | | //重置handler |
| | | resetHandler(); |
| | | HEARTTIMES = 2; |
| | | //发送心跳 |
| | | heart(); |
| | | } |
| | |
| | | public void onResume() { |
| | | super.onResume(); |
| | | isMySelfPage = true; |
| | | reconnect(); |
| | | textShowMac(); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | //暂停的时候不检测 |
| | | T.show("onPause"); |
| | | System.out.println("chenqi onPause"); |
| | | isMySelfPage = false; |
| | | stopReconnect(); |
| | | } |
| | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | System.out.println("chenqi onDestroy"); |
| | | EventBus.getDefault().unregister(this); |
| | | if (timer != null) { |
| | | timer.cancel(); |
| | |
| | | handler.postDelayed(reconnectRunnable, 0); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 停止重连 |
| | | */ |
| | | private void stopReconnect() { |
| | | handler.removeCallbacks(reconnectRunnable); |
| | | if (mBluetoothService != null) |
| | | mBluetoothService.closeConnect(); |
| | | } |
| | | |
| | | private void resetHandler() { |