On Thu, Jul 28, 2011 at 4:35 PM, Superjelli <[email protected]> wrote:
> I have got a Widget and it starts a task in onUpdate():
>
>                timer = new Timer();
>                myTime = new MyTime(appWidgetManager);
>                timer.scheduleAtFixedRate(myTime, 1, 10000);

Don't do that.

First, it does not work. Android will terminate your process and the
timer thread will go away, and later instances of your
AppWidgetProvider (e.g., your onDeleted() scenario) do not have access
to any of this.

Second, for the short period of time while it works, you are leaking
memory, since the AppWidgetProvider you used to create this thread
cannot be garbage collected.

Third, 10 seconds is more frequent than app widgets are designed to be updated.

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

Android Training in NYC: http://marakana.com/training/android/

-- 
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

Reply via email to