I have created a media player in android where the MediaPlayer is on a service. my main activity has an option menu with single item "exit" onOptionsItemSelected calls another method (mp is and instance of MediaPlayer in service)
private void exitPlayer() {
PlayerService.mp.stop();
onDestroy();
}
and onDestroy method is simple
protected void onDestroy() {
super.onDestroy();
if (!PlayerService.mp.isPlaying()) {
stopService(playerService);
cancelNotification();
finish();
}
}
but it throws
java.lang.RuntimeException: Unable to destroy activity java.lang.IllegalStateException
can any one help me? thanks