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. Incorporate a JavaScript to download from the app that creates a list of downloads from URL's...


I suppose you can do the parsing by yourself, so I will focus on the
clickable items list, when you parse the java script, you have already
had a list of item, all you need to do is to use the item as a data
source for the ListView using either BaseAdapter or other Adapters,
you can take a look at ApiDemo for more details,



2. How might I do this (HorizontalScrollView question)?

I have for screens/layouts I would like the user to be able to slide
between using a
horizontal scroll view.   Each screen has different information and
controls for the user.

I want each of the layouts to occupy the whole screen and the user
slides there finger left
and right to get to each of them.

I can do this by setting a layout_width to some size of 'dp'.

It would be nice if each layout could just be 'fill_parent' without
worrying about screen size.

Anybody have an example of how this might be done?

Thanks a lot.


3. How do I auto-generate code from xml like Android does it?

4. Animation tutorial

5. how to set proper screen for htc sprint compatibility.

6. Wired MarketPlace statistic - Total download count goes down!

7. How to prevent AlarmManager erased schedulations by TaskManager