private void initSoundWave() { try { sscStudioApi = new SSCstudioApi(context); sscStudioApi.setReceiveEnable(true); sscStudioApi.setUsbDetachNotifyCallback( new UsbDetachListener() { @Override public void usbDetachNotify() {} }); sscStudioApi.setDataReceiveCallback( new ReceiveListener() { @Override public void receiveData(byte[] data) { if (listener != null) { listener.onRecvData(data); } } }); } catch (Exception e) { e.printStackTrace(); } }
public void onDestroy() { try { if (null != soundWaveSendLooper) { soundWaveSendLooper.quit(); } } catch (Exception e) { e.printStackTrace(); } if (isSoundWaveLegal) { sscStudioApi.stop(); sscStudioApi.destroyResource(); } }
public void onStart() { isSoundWaveLegal = sscStudioApi.start(); if (isSoundWaveLegal) { HandlerThread soundWaveSendThread = new HandlerThread("soundWaveSendThread"); soundWaveSendThread.start(); soundWaveSendLooper = soundWaveSendThread.getLooper(); soundWaveSendHandler = new Handler(soundWaveSendLooper); soundWaveSendHandler.post(new soundWaveSendRunnable()); } }