Just Playlists 4.2.2—Fixed Problem with Unexpected Program Exits

I’ve found that JP has been unexpectedly stopping media playback and exiting for quite a while.  This would consistently occur after around a half-hour of run time.  It seemed to have started after an Android OS update in the past.  Examining the phone system log showed that the operating system was stopping the program, as if it didn’t know it was active and should be left to run.  The log message was flagged as  a “WIN DEATH” even.  I had thought I’d protected against this when I first created Just Playlists.  It turns out that–somewhere around Android version 2.1–programmers were being instructed to explicitly alert the OS that a running service shouldn’t be shut down as part of Android process management.  This is done via a  call to the startForeground() method.  When the service is in a state where shutdown is acceptable (such as not actively playing music), the stopForeground() method is to be called.  By adding these calls where appropriate within the code of Just Playlists, I have fixed the problem and JP no longer exits in this way.

I’ve also received reports from users that the program has been exiting when the screen is turned off on some devices.  The Archos Android tablet is one such device.  I am hoping that the change described above will also fix this problem.

As part of trying to work around this problem, I also added code to save track position every few seconds, such that if the program does crash or the OS shuts it down, the next time JP is run, the track that was playing should be ready to play again at the same position it was at before the shutdown.

Comments are closed.