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 much money do you make?

How much money have some have you made for how many apps for how long
of a time period?


2. why keyboard not launched from status bar edittext ??

Hi all,

 I implemented a edittext and a button on a status bar.

The problem i face here is, when the edittext is focused and i click
it, i couldnt see the Keyboard popup not happening.

But if i focus it, cursor blinks, and when i type some characters it
is handled by quick search box Activity(intent ).!!! (which ever
activity am in)
I have implemented onClick() function for editext. So that i thought
to launch the keyboard input forcefully, even then it doesnot work.!!

W/KeyCharacterMap(  144): No keyboard for id 0
W/KeyCharacterMap(  144): Using default keymap: /system/usr/keychars/
I/ActivityManager(   68): Starting activity: Intent
{ flg=0x10000000 (has extras) }
I/ActivityManager(   68): Start proc for
activity pid=331 uid=10026
I/ActivityManager(   68): Starting activity: Intent
{ flg=0x10000000 (has extras) }

what is the problem ?
How should i receive the keyboard popup first and characters typed in
being sent to edittext on the status bar.?

Can someone help me with this.

  private void makeStatusBarView(Context context) {

        urlTextbox = (EditText)sb.findViewById(;

        urlTextbox.setOnClickListener(new View.OnClickListener(){
                 public void onClick(View v) {

                             String url = urlTextbox.getText().toString();
                                System.out.println("Status Bar - Onclick of 
InputMethodManager inputMethodManager = (InputMethodManager)
mContext.getSystemService ( Context.INPUT_METHOD_SERVICE );
inputMethodManager.showSoftInput ( urlTextbox,
InputMethodManager.SHOW_FORCED );


        Button  mButton = (Button) sb.findViewById(;
        mButton.setOnClickListener(new Button.OnClickListener(){
                    public void onClick(View v) {

                             String url = urlTextbox.getText().toString();
                                System.out.println("Status Bar - Onclick of 
                             Intent browserIntent = new
Intent("android.intent.action.VIEW", Uri.parse("http://"));


I implemented in makestatusbarview()




3. Custom Title and Tab Host

4. global variable accessible by mapactiivty and activity

5. Auto mount setup for UMS in eclair 2.1 ?

6. Nokia inviting Developers to become an Ovi store publisher.

7. Force close/wait popup while in onCreate().