java - Playing media asynctask in a service cusses other asynctasks lock -



java - Playing media asynctask in a service cusses other asynctasks lock -

i having asynctask play media , using service it. problem when asynctask (in service) running, part of app used asynctask communicate web server not working until playing finishes. (playing media not buffering it).

i have tried removing asynctask , using new thread can't update ui in mode.

what should prepare it?

you don't want both asynctask , service. services designed long running background tasks. 'asynctask's designed launch new thread, perform long-running task, , send info ui thread.

there 1 ui thread, so, if you're updating ui, blocking user interaction.

if you're streaming music, want service spawn new thread can downloading songs in background. if, example, user presses button , loads video, might instead want asynctask perform download.

generally, 1 might utilize asynctask download media file on user request (or, if you're downloading in background, service might used this). info exchagned , video file can played using android's mediaplayertools:

http://developer.android.com/guide/topics/media/mediaplayer.html

remember that, unlike asynctask, creating service not automatically mean have created new thread. services can run on ui thread. speaking, though, utilize cases services require launch new thread work.

java android multithreading service android-asynctask

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -