Is this properly using a runnable?

by Jonathan » Fri, 26 Feb 2010 03:14:19 GMT

Sponsored Links
 I am basing an audioplayer off an old tutorial, and I am seeing some
major lag in my UI, which is making me think that the threading is not
being handled properly. It is structured as such:

    public void startStreaming() throws IOException {
        final String mediaUrl =
                Runnable r = new Runnable() {
                public void run() {
                    try {
                    } catch (IOException e) {
                        Log.e(getClass().getName(), "Unable to initialize the
MediaPlayer for fileUrl=" + mediaUrl, e);
            new Thread(r).start();

    public void downloadAudioIncrement(String mediaUrl) throws
IOException {
        //do audio downloading and buffering in here in here
        //there is not threading logic in here at all

I've ommitted the specific downloading code for brevity. Does calling
a function from a runnable mean that the logic will be run off the
main UI thread?

I can provide more specifics if need be. Thanks


Is this properly using a runnable?

by Gaunt Face » Sat, 27 Feb 2010 05:31:53 GMT

 are you updating the UI at all in the thread? From that code,
everything should be done in the background and therefore leave the
main UI happy, if however you are updating the UI, either the update
is taking to long outside of the thread or your updating it so often
that it is locking up the UI.

However I've not performed any task like this so couldn't say if there
were any specific case I might be missing.



Sponsored Links

Other Threads

1. android application error reports

Are there any details on this? There is an 'official' blog post, but
that tells us very little.

Is this a Froyo only feature? Or does it work for certain devices
only? I've being getting
reports from Motorola Droid for some time, and that are supposedly
running Eclair only
(at the time). I couldn't trigger it on my NexusOne though with stock
Eclair and Froyo.

BTW, it would be nice to get the Android version in the crash report.

Anyone care to shed some light?


2. OOT: Paging GilaOriginal

Permisi mods
Numpang jalum untuk paging rekan
Om iskandar tolong cek ym yah
Terima kasih mods :)


Desire by HTC

"Indonesian Android Community [id-android]" 

3. Detecting slow or unavailable network and black screen

4. Yahoo messenger update 1.0.2

5. Spinners identical in XML but look different when run

6. servicemanager crashing repeatedly

7. Medium density resources for v1.5 problems with workaround