AppWidget update best practices

by Nivek » Sun, 08 Nov 2009 16:27:09 GMT


Sponsored Links
 Hi !

In the process of creating an AppWidget which displays data from a
remote host, I am looking for documentation about how to manage
updates.

Are there articles somewhere about how and when querrying remote data
is the most appropriate ?

I am wondering if we have to explicitely code the remote querries in a
separate thread, or even do it in a separate service, to avoid freezes
of the home screen (this happens a lot on my htc magic).

Any tip and help is welcome !

Thanks !

--



AppWidget update best practices

by Mark Murphy » Sun, 08 Nov 2009 21:26:26 GMT


 


 http://android-developers.blogspot.com/2009/04/introducing-home-screen-widgets-and.html 

The above blog post shows using app widgets where the real work is being
done by a separate service.

To have the work be done on a background thread in that separate
service, have your service extend IntentService and override
onHandleIntent() rather than onStart().

You can see an example of this technique here:

 http://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/TwitterWidget/ 

99% of the time, you want to do any sort of "remote queries" on a
background thread.

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

Android App Developer Books:  http://commonsware.com/books 

--


Sponsored Links


AppWidget update best practices

by Nivek » Sun, 08 Nov 2009 22:41:05 GMT


 Thanks a lot, this is exactly what I was looking for.

I try this right now !

Kevin






--



Other Threads

1. LogCat logging wrong time

All the messages being logged in LogCat now have the wrong time.  It
is running about 35 minutes fast.  Any idea why or more importantly,
how to fix this?

-- 

2. Passsing a Cursor to a Activity

Hi!
Since Intent.putextra doesn't accept Cursor, what is the alternative
to pass a complex structure to a class?
For instance:

Cursor c; // assigned elsewhere
...
Intent myIntent = new Intent(this, my.class);
myIntent.putExtra("mycursor", c); // this won't work :-(
startActivity(myIntent);

... in my.java:
public my my extends Activity {
...

If the cursor is very complex, it will be a pain to mention each and
every item using putExtra (and then again in the receiving Activity).

Thanks in advance!

-- 

3. Android roadmap

4. onLowMemory not getting called

5. read gmail from android codee

6. DDMS use - allocated memory not freed when BACK pressed?

7. Probable bug with managed dialogs