public void onDestroy() { super.onDestroy(); try { m_instrumentService.unregisterCallback(m_callback); m_instrumentService.unloadSamples(m_sounds); unbindService(m_connection); } catch (RemoteException e) { e.printStackTrace(); } }
/** Do not reload sounds on screen rotation */ public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setContentView(R.layout.instrument_looper); try { // light up buttons for playing sounds for (Map.Entry<Integer, Integer> entry : m_buttonToSound.entrySet()) if (m_instrumentService.isPlaying(entry.getValue())) ((ToggleButton) findViewById(entry.getKey())).setChecked(true); // re-associate progress bars m_instrumentService.unregisterCallback(m_callback); for (Map.Entry<Integer, Integer> entry : m_soundToProgressID.entrySet()) m_soundToProgress.put(entry.getKey(), (ProgressBar) findViewById(entry.getValue())); m_instrumentService.registerCallback(m_callback); } catch (RemoteException e) { e.printStackTrace(); } }