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 Emulator Skins for Nexus S and Nexus One including Reflection Overlay


I published some Emulator skins for Nexus S and Nexus One (in
different colors). These skins had been built with respect to the
actual resolution and proportions of the device and feature a
reflection/glare effect overlay each you can activate as "onion".
Doing so allows you to produce high quality screencasts, take
screenshots or just wow your presentation audience ;)

Also, you can find a short tutorial about how to scale them back so
you can use them on small screens, too.

Feel free to download them at

Have fun!


2. EnvironmentalReverb unsupported operation exception in android

Hi everyone,

    When i am trying to use EnvironmentReverb class in android 2.3 i am 
getting exception UnsupportedOperation. Can anyone explain why i am getting 
this? I am just creating a new instance and i am getting this.

Thanks in advance.


3. Buyer鈥檚 Currency

4. Open AOSP apps in eclipse

5. Integrating Facebook To my App

6. Do existing scheduled items on the AlarmManager get cancelled after an application update from the Marketplace?

7. Is it possible to get android device id? (Urgent -- Please)