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 =
currentTrackData.get("play_url").toString();
                Runnable r = new Runnable() {
                public void run() {
                    try {
                                downloadAudioIncrement(mediaUrl);
                    } catch (IOException e) {
                        Log.e(getClass().getName(), "Unable to initialize the
MediaPlayer for fileUrl=" + mediaUrl, e);
                        return;
                    }
                }
            };
            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.

Cheers,
Matt




--


Sponsored Links


Other Threads

1. General Porting Information

Hello,
I am interested in experimenting with Android. I would like to port Android
to some hardware I have but I don't know where to start. Is there any high
level information about porting Android to new hardware?

I am assuming the following steps (from the 10,000 foot perspective):

1) Setup an Android development machine
2) Get the latest Android code
3) See if my hardware has an existing port of Android
4) If my hardware does not have an existing Android port see if it has an
existing Linux port
5a) If there is an existing linux port then diff the changes between the
Linux port and the latest android code
6) Once the merge is done then see if it works on the hardware
7) Lots and Lots of debugging

My impression is that this is mainly an excersize in Linux porting
expertise.
Is there any good information that will provide more details about taking on
this kind of activity?

Thanks

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Add one butten in a tab

hi!

I just started with android and now i have a problem!
I want to add a button in a tab. In time I just can show text and i don
t know how i add this button!

my code is:
in the .xml file:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TextView
                android:id="@+id/textview1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Tickets" />
            <TextView
                android:id="@+id/textview2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Tasks" />
            <TextView
                android:id="@+id/textview3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Settings" />
        </FrameLayout>
    </LinearLayout>
</TabHost>


and my .java file:

package com.example.workingcodes;


import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;

public class WorkingCodes extends TabActivity {
    /** Called when the activity is first created. */


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost mTabHost = getTabHost();

        mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator
("Tickets").setContent(R.id.textview1));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator
("Tasks").setContent(R.id.textview2));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator
("Settings").setContent(R.id.textview3));

        mTabHost.setCurrentTab(2);


    }
}


I want a button in the third tab! How i do this?! plz help!

wkr chri

--~--~---------~--~----~------------~-------~--~----~

3. i wish to join this group to get help for android x86 porting

4. unable to open an initial console in OMAP 2420

5. Additional Contact Information

6. ProgressDialog on Oncreate method

7. how and where to save SecretKey for encryption and decryption