/** * Releases internally used resources. This method should only be called when the object is not * used anymore. */ public void shutdown() { executor.shutdown(); if (mediaPlayer != null) { mediaPlayer.release(); } if (mediaSession != null) { mediaSession.release(); } releaseWifiLockIfNecessary(); }
/** * (non-Javadoc) * * @see android.app.Service#onDestroy() */ @Override public void onDestroy() { LogHelper.d(TAG, "onDestroy"); unregisterReceiver(mCarConnectionReceiver); // Service is being killed, so make sure we release our resources handleStopRequest(null); mCastManager = VideoCastManager.getInstance(); mCastManager.removeVideoCastConsumer(mCastConsumer); mDelayedStopHandler.removeCallbacksAndMessages(null); // Always release the MediaSessionCompat to clean up resources // and notify associated MediaControllerCompat(s). mSession.release(); }