I tried using a postDelayed like this:
final Runnable r = new Runnable()
{
public void run()
{
myBanner.refresh();
handler.postDelayed(this, 10000);
}
};
handler.postDelayed(r, 10000);
It still doesn't work. It updates continuously, instead of the ten seconds I
specified.
Thanks
On Thu, Aug 18, 2011 at 4:17 PM, Appaholics <[email protected]>wrote:
> I am only scheduling two timers, both using different names etc. I'll look
> into using postDelayed();
>
> Thanks
>
>
> On Thu, Aug 18, 2011 at 4:13 PM, Mark Murphy <[email protected]>wrote:
>
>> Why not use postDelayed()? It saves you a background thread, and your
>> Runnable gets invoked on the main application thread (which will be
>> necessary eventually for updating the ImageView or whatever the ad
>> banner is).
>>
>> I haven't used Timer/TimerTask on Android. Nothing leaps out at me as
>> being an issue with the code snippet, other than the background
>> thread. Are you sure you're not accidentally scheduling lots of
>> timers?
>>
>> On Thu, Aug 18, 2011 at 6:36 AM, Appaholics <[email protected]>
>> wrote:
>> > Hi,
>> > I am using the following to refresh my ad view every 30 seconds:
>> >
>> > Timer adTimer = new Timer("adUpdate");
>> >
>> > adTimer.scheduleAtFixedRate(new TimerTask() {
>> >
>> > public void run(){
>> >
>> > myBanner.refresh();
>> >
>> > }
>> >
>> > }, 0, 30000);
>> >
>> > However, it refreshes every half second or so, if the LogCat output is
>> to be
>> > believed. What is wrong in my code. The app doesn't crash but the update
>> > time isn't right.
>> >
>> > Thanks
>> >
>> > --
>> > --------------------
>> > Raghav Sood
>> > CEO/Founder/Owner/Dictator/Tyrant at Appaholics (Basically all titles
>> > required to have complete control)
>> > http://www.raghavsood.com/
>> > https://market.android.com/developer?pub=Appaholics
>> > http://www.appaholics.in/
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Android Developers" group.
>> > To post to this group, send email to
>> [email protected]
>> > To unsubscribe from this group, send email to
>> > [email protected]
>> > For more options, visit this group at
>> > http://groups.google.com/group/android-developers?hl=en
>>
>>
>>
>> --
>> Mark Murphy (a Commons Guy)
>> http://commonsware.com | http://github.com/commonsguy
>> http://commonsware.com/blog | http://twitter.com/commonsguy
>>
>> Warescription: Three Android Books, Plus Updates, One Low Price!
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>
>
> --
> --------------------
> Raghav Sood
> CEO/Founder/Owner/Dictator/Tyrant at Appaholics (Basically all titles
> required to have complete control)
> http://www.raghavsood.com/
> https://market.android.com/developer?pub=Appaholics
> http://www.appaholics.in/
>
>
--
--------------------
Raghav Sood
CEO/Founder/Owner/Dictator/Tyrant at Appaholics (Basically all titles
required to have complete control)
http://www.raghavsood.com/
https://market.android.com/developer?pub=Appaholics
http://www.appaholics.in/
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en