开发者

MediaPlayerService starts in background and blocks activity for a few seconds

I have searched for answer regarding this problem with no success. What is the situation?

I have TabWidget with two tabs. First one has activity that display video in VideoView. Second one displays images in GridView. When a GridView picture is clicked new Activity i开发者_JAVA技巧s started. It displays image in ImageView. The problem is: when I press back button, this last Activity holds for about 4,5 seconds before returning to tabs. I can see in LogCat that during that time MediaPlayerService starts the video that is in the first tab. I'm sure that this is the reason for that delay.

My question is: why does MediaPlaterService starts? It should display the tab that has nothing to do with VideoView. I'm obviously missing something, so please help.

Thanks in advance,

Shone


I managed to solve this problem but forgot to post the answer. Sorry about that.

The way I did it was removing the entire VideoView from the FrameLayot in onPause method of the first activity. In onResume() method I just recreated VideoView with its content and placed it back in FrameLayout. I was obviously consuming large amounts of memory.

Thanks CameronW, your suggestion got me started.

Shone


Without seeing your code, my guess would be your code to set up the VideoView is in a function that runs when the activity is started, such as onCreate. Move that code to a section of code that will not be called until its tab is clicked.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜