Also, Romain posted a great blog article about AsyncTask just a few days ago:

http://android-developers.blogspot.com/2009/05/painless-threading.html

j

On Tue, May 12, 2009 at 6:07 PM, Jeff Sharkey <jshar...@android.com> wrote:
> You should totally check out AsyncTask, it's designed for just this
> scenario of doing things in a background thread.  It can also handle
> sending periodic progress updates to the UI:
>
> http://d.android.com/reference/android/os/AsyncTask.html
>
> j
>
> On Tue, May 12, 2009 at 6:04 PM, radarcg <rada...@gmail.com> wrote:
>>
>> Ok, I'm really struggling with what is likely a simple issue. All I
>> really want to do is have an activity spawn a thread to do a non-
>> trivial action (for now, just testing with sleep(5000) ). Then, when
>> that non-trivial action completes,  the thread should notify the
>> activity, and the activity should present something visual, and
>> proceed. Simple enough right? I'm trying to use a Handler subclass to
>> which I send messages using sendMessage(). That handler subclass with
>> then notify the activity. It all seems to work actually, but then when
>> the thread completes, android is throwing an unhelpful exception:
>>
>>
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073): *** Uncaught remote
>> exception!  (Exceptions are not yet supported across processes.)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):
>> android.util.AndroidRuntimeException: { what=1004 when=4149225
>> arg2=1 } This message is already in use.
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> android.os.MessageQueue.enqueueMessage(MessageQueue.java:173)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> android.os.Handler.sendMessageAtTime(Handler.java:457)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> android.os.Handler.sendMessageDelayed(Handler.java:430)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> android.os.Handler.sendMessage(Handler.java:367)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> android.view.ViewRoot.windowFocusChanged(ViewRoot.java:2421)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> android.view.ViewRoot$W.windowFocusChanged(ViewRoot.java:2594)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at android.view.IWindow
>> $Stub.onTransact(IWindow.java:166)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> android.os.Binder.execTransact(Binder.java:287)
>> 05-13 00:58:14.476: ERROR/JavaBinder(1073):     at
>> dalvik.system.NativeStart.run(Native Method)
>>
>> As a seasoned Java developer, running into trouble like this so early
>> in a new project is frustrating. However, I believe in Android and the
>> broader Google development platforms, so I'd really like to solve
>> this, but I think I need the communities help. Even just some sample
>> code (skeleton apps) that demo some best practices regarding the
>> threading (such as usage of HandlerThread and Looper) would be a big
>> help.
>>
>> Thanks,
>>
>> Charles
>> >>
>>
>
>
>
> --
> Jeff Sharkey
> jshar...@google.com
>



-- 
Jeff Sharkey
jshar...@google.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to