Stopping playback when a MIDlet is switched to the background

When switching a MIDlet to the background, audio stream playback does not stop. Developers should implement stopping playback at the moment the MIDlet loses foreground. With a low-level UI, such as Canvas and GameCanvas, stopping playback can be implemented in the Canvas.hideNotify() method, which is called just after the MIDlet loses the foreground. Restarting playback can be implemented in the Canvas.showNotify() method, which is called just before the MIDlet returns to the foreground. With a high-level UI, such as List and Form, Displayable.isShown() can be used to check whether the calling Displayable is actually visible on the display. Developers can implement checking isShown() in a proper frequency to stop or restart playback.

On Nokia Asha software platform devices, the pauseApp() method can be used to stop media playback when the MIDlet is sent to the background. The startApp() can be similarly used to resume playback when the application is set in the foreground.