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
. service
s 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 mediaplayer
tools:
http://developer.android.com/guide/topics/media/mediaplayer.html
remember that, unlike asynctask
, creating service
not automatically mean have created new thread
. service
s can run on ui thread. speaking, though, utilize cases service
s require launch new thread
work.
java android multithreading service android-asynctask
Comments
Post a Comment