I have an AlertDialog, which stops playing a sound when I have clicked, but on some devices it appears that calling onStop() throws an IllegalStateException, but why?
If the dialog is up, that means the sound is playing, so it should be a case where the audio is not playing.
I surrounded it with a try catch for now, but what would cause this?
alert.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
try{
mp.stop(); //error
mp.reset();
mp.release();
}catch(Exception e){
Log.d("Nitif Activity", e.toString());
}
v.cancel();
popupMessage();
finish();
}
});
I guess you might be nulling your instance before executing these lines.
When I got this error I check for null first.