Skip to content Skip to sidebar Skip to footer

No Sound When The Activity Starts From Lock Screen

This seems to be a strange issue. I am using AlarmManager to set a alarm with custom audio track. The activity start and plays the music normally, but when i lock the phone the act

Solution 1:

I was able to figure out. And solved the problem. I had added a mediaplayer release in onStop and onPause method, and when the phone wakes up from the lock mode it was repetitively triggering onStop and onPause for some reason. So i added a isFinishing in onStop and onPause to make sure the activity is actually stopped.

if(this.isFinishing(){
   mediplayer.stop();
   mediplayer.release();
}

Solution 2:

Just adding to @RagZ anwer

If you are using Fragments then just replace isFinishing() with isRemoving().

if(this.isRemoving(){
   mediplayer.stop();
   mediplayer.release();
}

Post a Comment for "No Sound When The Activity Starts From Lock Screen"