AlarmManager + SQLite + Refresh Activity Screen

by RegisMelo » Mon, 09 May 2011 13:46:27 GMT


Sponsored Links
 Hello Everybody,

   I am developing an app that needs to refresh an information every X
minutes from a remote server. To do that I am scheduling an Alarm in
Android and persisting the data retrieved in a SQLite table.

   App's main activity shows this list retrieving from the same table
in SQLite. My doubt is very simple - how can I say to main activity
that exists fresh information in local database so the activity can
run a cursor.requery() to refresh the screen?

Regards,

RM

-- 



Re: AlarmManager + SQLite + Refresh Activity Screen

by Dianne Hackborn » Mon, 09 May 2011 15:02:14 GMT


 Two possible choices:

(1) Keep track of which activity(ies) are displaying data from the database
in a list of callbacks, so you can tell them when you change the data.

(2) Implement your database with a ContentProvider, which has a standard
model for reporting and responding to changes.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 


Sponsored Links


Other Threads

1. Home Screen Detection

I'm writing a back ground app and would like to be able to tell which
app is currently running (actually has focus).
I'm particularly interested in if the Home screen is being shown.
Can anyone help with this?
--~--~---------~--~----~------------~-------~--~----~

2. My issues with attempting to root my phone.

Phone:  T-Mobile G1, purchased used(barely) with firmware 1.1 on it.
Carrier:  Fido (they are a sub of Rogers and don't natively carry the
HTC Dream)

Phone worked fine by SMS stopped working 1.5 days after using it(coudl
receive but not send).  Called carrier 'reset' my account and SMS
worked for another 1.5 days.  Carrier 'did something' (I suspect it
was another 'reset') but nothing changed and I could not send or
receive SMS.  Been researching the pros/cons of rooting my phone and
decided that this is a good time to check it out.

I followed this process:

http://www.ryebrye.com/blog/2009/08/16/android-rooting-in-1-click-in-progress/

When I rebooted the phone to install the new image it hung for 'a very
long time' (wasn't timing it but I suspect it was about 5 mins) and
got nervous.  I rebooted the phone again, restored from the back and
it has been working since.

Ever since, though, Google Sky Map will not work.  Worked before but
not now.(watch this thread:

3. Unable to stop Emulator from commandline in linux

4. ShaSD Card Partitioning

5. how to read trace file

6. Device bug: Data SMS not received on Samsung Galaxy

7. How to enable USB Bluetooth for x86