开发者

Android: Confused about application states

I have seen this post here (http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state). I am having a similar pr开发者_如何学Pythonoblem I believe.

I have an app which listens to an audio stream (using the mediaPlayer object). If I press the Home button it will continue streaming and hide my app. Then, at a later point I can go back to my app and press stop when I'm done. This is what I want. If however I press the Back button, when I later open my app again the app has been redrawn from fresh. Text boxes, buttons, everything has reset like I've just opened the app for the first time so I can't stop my audio stream. Clicking stop does nothing because the app has 'forgotten' it is streaming (the stream runs under a separate handler from the main UI thread, so I'm guessing since its been 'reset' it has lost track of its handlers?).

Why does this happen with the Back button, and how can I stop it?


Move the streaming functionality into an Android Service. Use an Activity to bind to the Service and to interact with it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜