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. How to enable search functionality to EditText

Hi friends,

I would like to enable search functionality to EditText.

my requirement is like this:
when some one types with some letter, suppose the user types 'a', then
it should show all the words which starts with 'a' should be shown as
a drop down list.

For example, if I first typed "copy" in the EditText, if again, I
cleared the EditText and tried to type "co", then it should show the
drop-down list "copy","come","cow"....

I want to enable this feature to my EditText view.

Can any one please suggest me how to do this?


2. Implimenting Buttons

Hey guys, I know that this is most likely the most n00bish question
asked in this group, but I'm pulling my hair out here.  I am currently
enrolled in Software Engineering at University and have just finished
a module on Java programming , so Java isn't new to me.  But for the
life of me, I just cannot impliment buttons into my app.  What I need
to do is to have 3 buttons, each calling the same method but passing a
different parameter into the method.  I have tried various methods
such as:

public void onCreate(Bundle savedInstanceState) {

                // Capture our button from layout
                Button button = (Button) findViewById(;
                // Register the onClick listener with the implementation above

private OnClickListener mCorkyListener = new OnClickListener() {
                public void onClick(View v) {
                        if (v.getId() == {
                            } else {
                        Log.d("DEBUGTAG", "onClick called");

And each time it force closes, the LogCat states that it is due to

If anyone could help, I would be very grateful.

Thank you in advance.


3. How get horizontal and vertical events in android

4. Android INIT not loading firmware

5. How to manage Delay in InputStream ?

6. UK Developers

7. Store completely open?