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. anyone know what is the "@SdkConstant" before the "public static final String"

I read the code in the intent.java, there have a lot of definition
like following:

    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_ATTACH_DATA =
"android.intent.action.ATTACH_DATA";

I don't konw why the @SdkConstant identifiers before the declair
public static final String ACTION_ATTACH_DATA ?

What's the action for the @SdkConstant ??

sorry for my poor java lanaguage ability.

-- 

2. web service that collects and analyzes any data about domains and keywords http://alturl.com/mdsd

web service that collects and analyzes any data about domains and
keywords http://alturl.com/mdsd

-- 

3. Analyzes any data about domains and keywords http://alturl.com/mdsd

4. Android Market updating in error

5. Nexus One User Guide

6. Source code for Android 2.0 (Eclair)

7. Fw: Buku "membuat aplikasi untuk Android" sudah ready