Re: [android-developers] Update ad view every 30 seconds

2011-08-19 Thread Jim Graham
On Fri, Aug 19, 2011 at 08:02:47AM -0400, Mark Murphy wrote:
> On Fri, Aug 19, 2011 at 7:56 AM, Jim Graham  wrote:
> > Would that equivalent be Project->Clean, which does a clean first,
> > then builds (but by default, does so for every project in Eclipse)?
> 
> Sorry -- I meant I didn't know how to do that on every build. Yes,
> that's how you clear up the issue, but you're either manually doing a
> Project->Clean each build or your are waiting for odd stuff to happen,
> then doing a Project->Clean.


> Anyone know how to automate that better in Eclipse?  I confess that I
> still wield Eclipse like a blunt instrument...

First, note that because my laptop is FAR from the dual core 10 TB RAM
200 THz CPU (ok, that's a slight exaggeration ) system that's
required to run the emulator, I have to do all work using my Motorola
Bravo (MB520) for development.  I also have not tried actually using
it as the emulator (i.e., run from Eclipse, not install with adb[1] and
THEN run from my phone, which is what I do now).  So this is based on
that

In my case, then, it's either Project-->Build or Project-->Clean and
then OK (or whatever it is) in the popup to tell it to proceed.

Later,
   --jim

[1] and I have a zsh alias for that:
alias adbinstall='c:/android/android-sdk/platform-tools/adb install -r'

-- 
73 DE N5IAL (/4)MiSTie #49997  < Running FreeBSD 7.0 >
spooky1...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W

Do not look into laser with remaining eye!

Android Apps Listing at http://www.jstrack.org/barcodes.html

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Update ad view every 30 seconds

2011-08-19 Thread Mark Murphy
On Fri, Aug 19, 2011 at 7:56 AM, Jim Graham  wrote:
> Would that equivalent be Project->Clean, which does a clean first,
> then builds (but by default, does so for every project in Eclipse)?

Sorry -- I meant I didn't know how to do that on every build. Yes,
that's how you clear up the issue, but you're either manually doing a
Project->Clean each build or your are waiting for odd stuff to happen,
then doing a Project->Clean. Whereas with the command-line builds, ant
clean install was just a matter of course (and six extra keystrokes).

Anyone know how to automate that better in Eclipse?  I confess that I
still wield Eclipse like a blunt instrument...

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.9 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Update ad view every 30 seconds

2011-08-19 Thread Jim Graham
On Fri, Aug 19, 2011 at 06:45:10AM -0400, Mark Murphy wrote:
> 
> If you do command-line builds, I always recommend chaining clean onto
> your target list (e.g., ant clean install), unless you have a really
> big project and a really slow development machine.
> 
> Alas, I don't know the equivalent in Eclipse.

Would that equivalent be Project->Clean, which does a clean first,
then builds (but by default, does so for every project in Eclipse)?

Later,
   --jim

-- 
73 DE N5IAL (/4)  | 1) "Smoking habanero powder helps defeat that
< Running FreeBSD 7.0 >   |off taste' quite nicely."
spooky1...@gmail.com  | 2) "I figure a couple bong hits of [habanero]
ICBM/Hurr.: / 30.44406N   |powder would defeat just about anything!"
| 86.59909W--seen in Chile-Heads list

Android Apps Listing at http://www.jstrack.org/barcodes.html

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Update ad view every 30 seconds

2011-08-19 Thread Appaholics
I use eclipse and the speed of my machine is not a problem (i7, 2.0 x 8 ghz)

Thanks

On Fri, Aug 19, 2011 at 4:15 PM, Mark Murphy wrote:

> On Fri, Aug 19, 2011 at 3:16 AM, Appaholics 
> wrote:
> > No I got it working. The method Mark suggested was fine. Some error in
> > R.java cause a resource on my sensor change to be reffered to as the same
> > one, calling it again and again. I deleted R.java, had it recreated and
> now
> > it is fine.
>
> If you do command-line builds, I always recommend chaining clean onto
> your target list (e.g., ant clean install), unless you have a really
> big project and a really slow development machine.
>
> Alas, I don't know the equivalent in Eclipse.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 3.9 Available!
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Update ad view every 30 seconds

2011-08-19 Thread Mark Murphy
On Fri, Aug 19, 2011 at 3:16 AM, Appaholics  wrote:
> No I got it working. The method Mark suggested was fine. Some error in
> R.java cause a resource on my sensor change to be reffered to as the same
> one, calling it again and again. I deleted R.java, had it recreated and now
> it is fine.

If you do command-line builds, I always recommend chaining clean onto
your target list (e.g., ant clean install), unless you have a really
big project and a really slow development machine.

Alas, I don't know the equivalent in Eclipse.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.9 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Update ad view every 30 seconds

2011-08-19 Thread Appaholics
No I got it working. The method Mark suggested was fine. Some error in
R.java cause a resource on my sensor change to be reffered to as the same
one, calling it again and again. I deleted R.java, had it recreated and now
it is fine.

Thanks

On Fri, Aug 19, 2011 at 5:58 AM, TreKing  wrote:

> This might help:
> http://developer.android.com/resources/articles/timed-ui-updates.html
>
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Update ad view every 30 seconds

2011-08-18 Thread TreKing
This might help:
http://developer.android.com/resources/articles/timed-ui-updates.html

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Update ad view every 30 seconds

2011-08-18 Thread Mark Murphy
Nothing obvious. Create yourself a scrap project that just does the
postDelayed() quasi-loop, logging to LogCat. You should see it simply
show up every 10 seconds.

On Thu, Aug 18, 2011 at 7:08 AM, Appaholics  wrote:
> I am using the greystripe SDK, for which I need to call myBanner.refresh();.
> the same call works fine in another one of my apps when I call it at game
> over. However, here there is no moment at which I can call it and hence must
> run it every 10 seconds. I only call the runnable in onCreate as you can
> see:
>
> @Override
>
>     public void onCreate(Bundle savedInstanceState) {
>
>         super.onCreate(savedInstanceState);
>
>         setContentView(R.layout.main);
>
>         handler=new Handler();
>
>         myBanner = (BannerView) findViewById(R.id.gsBanner);
>
>         ads.initialize(this, "mykey");
>
>         accelerationTextView = (TextView) findViewById(R.id.acceleration);
>
>         maxAccelerationTextView = (TextView)
> findViewById(R.id.maxAcceleration);
>
>         sensorManager = (SensorManager)
> getSystemService(Context.SENSOR_SERVICE);
>
>
>
>         Sensor accelerometer =
> sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
>
>         sensorManager.registerListener(sensorEventListener, accelerometer,
> SensorManager.SENSOR_DELAY_FASTEST);
>
>
>
>         Timer updateTimer = new Timer("gForceUpdate");
>
>         updateTimer.scheduleAtFixedRate(new TimerTask() {
>
>         public void run(){
>
>         updateGUI();
>
>         }
>
>         }, 0, 5);
>
>         final Runnable r = new Runnable()
>
>         {
>
>             public void run()
>
>             {
>
>             handler.postDelayed(this, 1);
>
>             myBanner.refresh();
>
>             }
>
>         };
>
>         handler.postDelayed(r, 1);
>
>
>
>     }
>
> Does anything jump out at you?
>
> Thanks
>
> On Thu, Aug 18, 2011 at 4:32 PM, Mark Murphy 
> wrote:
>>
>> On Thu, Aug 18, 2011 at 6:55 AM, Appaholics 
>> wrote:
>> > I tried using a postDelayed like this:
>> >
>> >         final Runnable r = new Runnable()
>> >
>> >         {
>> >
>> >             public void run()
>> >
>> >             {
>> >
>> >             myBanner.refresh();
>> >
>> >             handler.postDelayed(this, 1);
>> >
>> >             }
>> >
>> >         };
>> >
>> >         handler.postDelayed(r, 1);
>> >
>> > It still doesn't work. It updates continuously, instead of the ten
>> > seconds I
>> > specified.
>>
>> Either you are calling this too often (thereby scheduling lots of
>> Runnables), or the problem lies in myBanner.refresh() somewhere.
>>
>> --
>> 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 android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> 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/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Update ad view every 30 seconds

2011-08-18 Thread Appaholics
I am using the greystripe SDK, for which I need to call myBanner.refresh();.
the same call works fine in another one of my apps when I call it at game
over. However, here there is no moment at which I can call it and hence must
run it every 10 seconds. I only call the runnable in onCreate as you can
see:

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

handler=new Handler();


myBanner = (BannerView) findViewById(R.id.gsBanner);

ads.initialize(this, "mykey");

accelerationTextView = (TextView) findViewById(R.id.acceleration);

maxAccelerationTextView = (TextView)
findViewById(R.id.maxAcceleration);

sensorManager = (SensorManager)
getSystemService(Context.SENSOR_SERVICE);



Sensor accelerometer =
sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

sensorManager.registerListener(sensorEventListener, accelerometer,
SensorManager.SENSOR_DELAY_FASTEST);



Timer updateTimer = new Timer("gForceUpdate");

updateTimer.scheduleAtFixedRate(new TimerTask() {

public void run(){

updateGUI();

}

}, 0, 5);

final Runnable r = new Runnable()

{

public void run()

{

handler.postDelayed(this, 1);

myBanner.refresh();

}

};


handler.postDelayed(r, 1);



}


Does anything jump out at you?


Thanks

On Thu, Aug 18, 2011 at 4:32 PM, Mark Murphy wrote:

> On Thu, Aug 18, 2011 at 6:55 AM, Appaholics 
> wrote:
> > I tried using a postDelayed like this:
> >
> > final Runnable r = new Runnable()
> >
> > {
> >
> > public void run()
> >
> > {
> >
> > myBanner.refresh();
> >
> > handler.postDelayed(this, 1);
> >
> > }
> >
> > };
> >
> > handler.postDelayed(r, 1);
> >
> > It still doesn't work. It updates continuously, instead of the ten
> seconds I
> > specified.
>
> Either you are calling this too often (thereby scheduling lots of
> Runnables), or the problem lies in myBanner.refresh() somewhere.
>
> --
> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Update ad view every 30 seconds

2011-08-18 Thread Mark Murphy
On Thu, Aug 18, 2011 at 6:55 AM, Appaholics  wrote:
> I tried using a postDelayed like this:
>
>         final Runnable r = new Runnable()
>
>         {
>
>             public void run()
>
>             {
>
>             myBanner.refresh();
>
>             handler.postDelayed(this, 1);
>
>             }
>
>         };
>
>         handler.postDelayed(r, 1);
>
> It still doesn't work. It updates continuously, instead of the ten seconds I
> specified.

Either you are calling this too often (thereby scheduling lots of
Runnables), or the problem lies in myBanner.refresh() somewhere.

-- 
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Update ad view every 30 seconds

2011-08-18 Thread Appaholics
I tried using a postDelayed like this:

final Runnable r = new Runnable()

{

public void run()

{

myBanner.refresh();

handler.postDelayed(this, 1);

}

};


handler.postDelayed(r, 1);


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 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 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 
>> 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, 3);
>> >
>> > 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
>> android-developers@googlegroups.com
>> > To unsubscribe from this group, send email to
>> > android-developers+unsubscr...@googlegroups.com
>> > 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 android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Update ad view every 30 seconds

2011-08-18 Thread Appaholics
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 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 
> 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, 3);
> >
> > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Update ad view every 30 seconds

2011-08-18 Thread Mark Murphy
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  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, 3);
>
> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Update ad view every 30 seconds

2011-08-18 Thread Appaholics
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, 3);


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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en