A timer thread and url fetch thread in same activity.

by Droid » Fri, 20 May 2011 04:57:45 GMT

Sponsored Links
 I am having problems with a timer that should fetch http results from
the web every 5 minutes.
I having problems with two threads - often I cannot even turn them off
or keep the timer going without upsetting the apple cart.

Should I start using wait() and notify(), a separate service or
continue trying to get them to be friends with each other in the same
activity. At present its all very badly behaved and I feel as though I
am juggling with marbles.


Re: A timer thread and url fetch thread in same activity.

by TreKing » Fri, 20 May 2011 05:06:37 GMT


Just saying you're using two threads is a red flag. What apple cart?

Use a handler to schedule a message to go off in 5 minutes. When that
message is delivered, use an AsyncTask to do the fetch and handle the
results when it completes.

No raw threads necessary.

TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices


Sponsored Links

Other Threads

1. Android Logging

What is the best approach to catch unexpected exceptions and log them

I have used the Debug.startMethodTracing() method to create trace

but the problem is if the application errors out, the
Debug.stopMethodTracing() never gets called
so the trace information is lost..

if there another way

also I have tried to capture the logcat like

 mLogcatProc = Runtime.getRuntime().exec("logcat -f /sdcard/App.log
'*:D App_TAG:V'");

the file gets created but its empty...

any ideas...

2. Changed file permissions in Donut 1.6 stops TRIAL software

Yes, that changed because we absolutely do not want applications doing just
this kind of thing -- throwing junk in places the user can't get rid of. :/

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


3. Refractoring XML in eclipse

4. fail in video recording for "Run writeAsync error"

5. OnCompletion video notification on MediaController and VideView usage?

6. Putting a Webview in a Tab Content