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. Spica EXXJCE Custom MOD leMOD

ada yg ngalamin jg gak?
kok dibanding waktu make EDXJB + root beda bgt ya, yg ini lemod pdahal udah
mati2in app gak kepake
kaya lg nye-croll di pasar malam, ngelag2 gt scrollingnya. buka messaging
gak secepet EDXJB jg.

kalo EXXJCE yg tanpa custom MOD gmn tu? belum sempet nyobain soalnya, begitu
flash ke EXXJCE lsng flash lg custom MODnya :D

jd pengen balik ke EDXJB aja rasanya :(

-- spica user --

-- 
"Indonesian Android Community [id-android]" 

2. Can't get animations working.

I am trying to create a menu that slides in when it is drawn. I
created an animation in res/anim called map_toolbar_in.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromYDelta="100%"
        android:toYDelta="0%"
        android:duration="150"/>

Then I have a linearLayout which I attempt to use it in:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
              android:id="@+id/zoom_buttons"
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentRight="true"
              android:layout_alignParentTop="true"
              android:layout_marginTop="20dp"
              android:layout_marginRight="20dp"
              android:layoutAnimation="@anim/map_toolbar_in"
              >
</LinearLayout>

When I run the program I get a bunch of errors, starting with:

04-05 18:17:05.287: ERROR/AndroidRuntime(4258): Caused by:
java.lang.RuntimeException: Unknown layout animation name: translate
04-05 18:17:05.287: ERROR/AndroidRuntime(4258):     at
android.view.animation.AnimationUtils.createLayoutAnimationFromXml(AnimationUtils.java:
178)
04-05 18:17:05.287: ERROR/AndroidRuntime(4258):     at
android.view.animation.AnimationUtils.createLayoutAnimationFromXml(AnimationUtils.java:
153)
04-05 18:17:05.287: ERROR/AndroidRuntime(4258):     at
android.view.animation.AnimationUtils.loadLayoutAnimation(AnimationUtils.java:
134)
04-05 18:17:05.287: ERROR/AndroidRuntime(4258):     at
android.view.ViewGroup.initFromAttributes(ViewGroup.java:343)
04-05 18:17:05.287: ERROR/AndroidRuntime(4258):     at
android.view.ViewGroup.<init>(ViewGroup.java:286)

Does anyone have any ideas?

-- 

3. Almost 10k Android Apps Added In March [Android Market Continues To Grow, Android vs iPhone Gets Mo re Interesting All The Time] 禄 TFTS 鈥?Technology, Gadgets & Curiosities

4. Question on showing contacts with all numbers

5. which folder is the protocol source code for data service (packet service)

6. EditText functionality

7. How to detect "blowing in to the microphone"?