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. How could I run a Uri based Intent in a Tab Page?

Sorry, currently a TabHost can only run activities that are part of your own
.apk (actually only those with the same uid, but in most cases that is the
same thing).






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

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.

--~--~---------~--~----~------------~-------~--~----~

2. autoLink text from app widget

Hi,

I have an app widget with a TextView in it. I set its android:autoLink
property to "web|map" so that the links can be clicked to launch them in
browser.

The links become clickable alright, but when I click on them an exception is
thrown while opening the browser Activity.

E/AndroidRuntime( 5923): android.util.AndroidRuntimeException: Calling
startActivity() from outside of an Activity  context requires the
FLAG_ACTIVITY_NEW_TASK flag. Is this really what you
want?
E/AndroidRuntime( 5923):        at
android.app.ApplicationContext.startActivity(ApplicationContext.java:627)

E/AndroidRuntime( 5923):        at
android.text.style.URLSpan.onClick(URLSpan.java:62)

E/AndroidRuntime( 5923):        at
android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:216)

E/AndroidRuntime( 5923):        at
android.widget.TextView.onTouchEvent(TextView.java:6315)

E/AndroidRuntime( 5923):        at
android.view.View.dispatchTouchEvent(View.java:3368)
....

This shows as "The process android.process.acore has stopped
unexpectedly..." on screen.

Since I am not launching the Browser activity in my code, I don't know where
I can mention the FLAG_ACTIVITY_NEW_TASK flag.

Any ideas?

Thanks in advance.

Jayesh

--~--~---------~--~----~------------~-------~--~----~

3. How do you display many points on a map?

4. How to get past "waiting for for device /dev/block/sdb2" on eee PC 1000HE?

5. ubuntu brainstorm

6. How I can attach other drawable image on drawable image?

7. How to get past "waiting for for device /dev/block/sdb2" on eee PC 1000HE?