Jan 20 | 9:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Prasanna P. | has entered the room |
Mark M. |
howdy, Prasanna!
|
Prasanna P. |
Hi Mark
|
Jan 20 | 9:30 PM |
Prasanna P. |
Here is my question
|
Jan 20 | 9:30 PM |
Prasanna P. |
Just want to run this by you ...
|
Jan 20 | 9:30 PM |
NetApex | has entered the room |
Prasanna P. |
The scenario is that we want to create a
background service that downloads information and makes it available to
several widgits. These widgits should know when there is new
information that is downloaded from the service. The widgits should
also get access to this information when ever it wants to based on how
the user interacts with the widgit. What is a good architecture for
this? That is, do we need a remote service? Is it a good idea to get
the background service to store the information in a mysql database and
make this information available through a content provider? The widgit
will need to change this data also. Should we let the widgits know that
there is new information though a broadcast? Is there a good example
of this?
|
Mark M. |
By "widgits" do you mean "app widgets"?
|
Prasanna P. |
Yes.
|
Mark M. |
(btw, howdy, NetApex!)
|
NetApex |
Hello
|
Mark M. |
"That is, do we need a remote service?" -- absolutely not
|
Mark M. |
"Is it a good idea...content provider?" -- use
AlarmManager and an IntentService to gather the data. How you make it
available to the rest of your app is up to you.
|
Prasanna P. |
Wont the service and Widget run in different processors
|
Mark M. |
"Should we let the widgits know that there is new
information through a broadcast?" -- no, because that is impossible.
Just update the app widgets directly when the data changes.
|
fitz | has entered the room |
Mark M. |
"Wont the service and Widget run in different processors" -- no
|
Mark M. |
while the app widget is displayed in a different process, that does not impact your code
|
fitz |
no specific questions from me today
|
Jan 20 | 9:35 PM |
Mark M. |
NetApex: do you have a question?
|
Prasanna P. |
But if the widget want's to get access to an api
that is exposed by the service then don't we need to implement a remote
service?
|
Prasanna P. |
sorry I can wait for NetApex to ask a question
|
NetApex |
Just one, and it is more of an, I need your opinion type of thing. (Go ahead and ask P)
|
Mark M. |
Prasanna: widgets do not have "wants", because they do not have code, per se
|
Mark M. |
widgets are RemoteViews
|
Mark M. |
they are data structures
|
Mark M. |
anything in your app can update the app widget RemoteViews whenever you want
|
Mark M. |
so, app widgets do not "get access to an api that is exposed by the service" -- the service updates the app widget's RemoteViews
|
Mark M. |
or something else (e.g., AppWidgetProvider) calls some API from the service and updates the RemoteViews
|
Prasanna P. |
so if the AppWidgetProvider wants to get access to the service, don't we need to create a remote
|
Prasanna P. |
service
|
Mark M. |
no
|
Mark M. |
the AppWidgetProvider is just a BroadcastReceiver running in your regular process
|
Jan 20 | 9:40 PM |
Prasanna P. |
I am a little confused about the different processes that are involved ...
|
Mark M. |
everything is in your process except for the home screen
|
Prasanna P. |
ok. different apps of course run on different processes, right?
|
Mark M. |
yes
|
Prasanna P. |
ok. got it.
|
Mark M. |
the home screen runs in its process
|
Mark M. |
it receives RemoteViews from your app
|
Mark M. |
and displays them in the app widget block of cells
|
Prasanna P. |
ok. I have more q's but can wait till it's my turn next ...
|
NetApex |
I am working on an app that pulls data off of
Google App Engine. I am wondering if I should have the data save into a
database in the app, or just rely on there being a network connection.
Say it was the score of a game and it is updated once or twice a week.
If one were to view the data yesterday, and then reopen the app today
without a network connection would the data be stored in memory, or
would it rely on a specific database being created to keep the data
there?
|
Mark M. |
that's impossible to say
|
Jan 20 | 9:45 PM |
Mark M. |
it depends on how much the user uses their phone and whether Android felt the need to kick the activity out of RAM
|
NetApex |
Ahh okay, so basically it would be best to create a database just in case
|
Mark M. |
if the activity is still around, it would show whatever the activity had before
|
Mark M. |
that would be my recommendation, yes, unless the data set is the size of Mount Rushmore
|
Mark M. |
and here I thought the opinion you wanted was my pick for the NFC Championship Game
|
NetApex |
Lol, well, since we have you here...
|
Mark M. |
(Packers, in honor of my namesake, the president/CEO over there)
|
NetApex |
Well... you can't be right about everything I suppose ;)
|
Mark M. |
oh, no, Mark Murphy is definitely the president/CEO of the Green Bay Packers
|
Mark M. |
oh, wait, you mean on the game outcome...
|
NetApex |
Ok for the database, drop and create a new one with each update, or do the official update the database itself thing?
|
Mark M. |
that would depend on the data, I suppose
|
Mark M. |
my gut instinct is to upgrade the database and leave the data there
|
NetApex |
Ok, then I need to go learn how to correctly do that stuff. Thanks yet again.
|
Mark M. |
ALTER TABLE, wherever possible
|
Jan 20 | 9:50 PM |
NetApex |
Any chapter I should be looking at?
|
Mark M. |
fitz: chime in if you come up with a question, so you get in the rotation
|
Mark M. |
I don't think I have ALTER TABLE anywhere, except probably the LunchList tutorials
|
Mark M. |
onUpgrade() in SQLiteOpenHelper is covered in the Database chapter in the BCG to Android Development
|
Mark M. |
Prasanna: you said you had another question?
|
NetApex |
Ok, LunchList is my favorite tutorial for learning stuff anyway. I have used it a lot in making everything I have tried.
|
Prasanna P. |
So how would the service inform the widget that there is new data for it?
|
Mark M. |
it wouldn't
|
Mark M. |
it would use AppWidgetManager to update the RemoteViews
|
Prasanna P. |
ok.
|
Prasanna P. |
Can the background service store data a mysql database?
|
Mark M. |
well, there is no MySQL on Android
|
Mark M. |
if you mean SQLite, yes
|
Mark M. |
if you mean a Web service that is backed by MySQL, yes
|
Prasanna P. |
yes. sorry.
|
Prasanna P. |
I mean sqlite on the android device
|
Prasanna P. |
I basically was thinking of
|
Prasanna P. |
storing the data that is downloaded by the background service
|
Jan 20 | 9:55 PM |
Prasanna P. |
in a sqllite data base and making this data available to the AppWidgetManager as a content provider. Does this make sense
|
Mark M. |
um, maybe
|
Mark M. |
you implement an AppWidgetProvider
|
Mark M. |
it gets called when the app widget is added to the home screen and removed from the home screen
|
Mark M. |
and, if you use updatePeriodMillis, it will be called to update the RemoteViews
|
Mark M. |
if you want that stuff to access the database (whether through a content provider or not), that's fine
|
Mark M. |
AppWidgetManager is the class that actually sends the RemoteViews to the home screen
|
Mark M. |
you call it from AppWidgetProvider or anything else that is updating the RemoteViews
|
Mark M. |
AppWidgetManager, therefore, has no direct relationship with your database or content provider
|
Prasanna P. |
ok. and the background service will be able to write to the sqllite db right?
|
Mark M. |
yes, all components in your app can work with your SQLite datbaase
|
Mark M. |
er, database
|
Jan 20 | 10:00 PM |
Prasanna P. |
How to get a background service to wake up and do work after a certain time period?
|
Mark M. |
AlarmManager
|
Mark M. |
covered in the BCG to Advanced Android Development
|
Mark M. |
(BTW, NetApex, since we have a small group, feel free to ask other questions if you have them)
|
Prasanna P. |
ok. How to get a background service to run every time the phone is turned on?
|
Mark M. |
set up a BroadcastReceiver to watch for BOOT_COMPLETED
|
Mark M. |
also covered in the BCG to Advanced Android Development
|
NetApex |
I am good for the moment, although listening to his questions has me thinking about how to best make use of C2DM now.
|
Mark M. |
NetApex: beyond what I have in the book, I haven't touched C2DM
|
Mark M. |
("the book" being BCG to Advanced Android Development)
|
Jan 20 | 10:05 PM |
NetApex |
ok, I will go over what is in there and at least it will start me off
|
Prasanna P. |
So, in general for a background service to
download quite a bit of data that needs to be displayed on a widget,
what would be a good high level architecture?
|
Mark M. |
I cannot really answer that question
|
Mark M. |
to put it another way, that's somewhat more involved than would really fit in a chat session
|
Prasanna P. |
ok
|
Jan 20 | 10:10 PM |
Prasanna P. |
Mark, I am going to head out. Thanks a lot for your help today!
|
Mark M. |
see you later!
|
Prasanna P. | has left the room |
Mark M. |
anyone have any questions?
|
NetApex |
Another off the cuff question...
|
NetApex |
Have you played with app engine?
|
Mark M. |
if you mean Google App Engine, not much
|
Mark M. |
I decided I didn't like the approach
|
Mark M. |
I'd rather use Slicehost or Amazon Web Services
|
NetApex |
Really? You are the second person I have heard talk about Amazon instead
|
NetApex |
Never heard of Slicehost, but now I will have to have a look
|
NetApex |
Why do you prefer those two over GAE?
|
Mark M. |
it's a virtual private server firm
|
fitz |
NetApex - it sounds like your doing a bit of the
same stuff I am - Google does not have an samples for Apps yet - drag -
you find any good resources?
|
Mark M. |
NetApex: both Amazon EC2 and Slicehost give you Linux environments to run what you want
|
Mark M. |
you aren't limited to specific structures like GAE does
|
NetApex |
Hmm, interesting.
|
Mark M. |
with GAE, you're adding coding headache to save administration headache
|
NetApex |
Yeah fitz, maybe we should talk sometime lol
|
Jan 20 | 10:15 PM |
NetApex |
I see
|
fitz |
NetApex - ya e-mail me tomorrow when you can see if we can connect redacted
|
NetApex |
will do
|
fitz |
thanks - Mark are all books updated now?
|
Mark M. |
fitz: do you want that address in the transcript? if not, I'll try to remember to remove it before posting the transcript
|
fitz |
to 2.3 I mean
|
Mark M. |
fitz: BCG to Advanced Android Development needs an update to Android 2.3 -- should be ready by the end of the month
|
fitz |
ya please remove e-mail address :)
|
Mark M. |
the other two are updated
|
fitz |
did not think of that :) long day
|
fitz |
ok on books thanks - will have to pull them and do MORE READING
|
NetApex |
Hehe yeah same here, I am going to go over them again this weekend
|
fitz |
ok thanks Mark I am bolting
|
fitz | has left the room |
Jan 20 | 10:20 PM |
NetApex |
and then there were two
|
NetApex |
I am pretty much out of questions for now until I read up some more on how to do some things
|
Mark M. |
no, more like one and a half
|
Mark M. |
I've had a rough day
|
NetApex |
Hehe
|
NetApex |
Will you be doing any training around the MidWest?
|
Mark M. |
I have nothing scheduled
|
Mark M. |
right now, I only do public training with Big Nerd Ranch (Atlanta) and Skills Matter (London)
|
Mark M. |
other than maybe little one-day affairs
|
Mark M. |
ChicagoAndroid ran a couple of those last year
|
NetApex |
I would be able to make those if you made it back to Chicago
|
NetApex |
Although hopefully it would be after May... saving up for the Google I/O
|
Mark M. |
there's an Android training firm in Chicago trying
to get some traction, so I suspect that ChicagoAndroid would prefer to
help the local folk
|
Mark M. |
ah, yes
|
Mark M. |
surprised they haven't opened registration yet
|
NetApex |
Are you going there this year?
|
NetApex |
I am too.. been waiting since the 4th
|
Mark M. |
it's on my calendar
|
NetApex |
Coolio, it would be cool to meet you
|
Mark M. |
the challenge will be getting tickets
|
Mark M. |
it sold out in a few weeks last year, as I recall
|
NetApex |
the day registration opens I will be all over it
|
Jan 20 | 10:25 PM |
Mark M. |
it'll be interesting if the new Google CEO makes an appearance there
|
NetApex |
http://googlecode.blogspot.com/2010/06/sav…
- Very first comment is exactly what I did that day. Started
tossing money aside so that I would be ready when it was announced.
|
NetApex |
I always thought the CEO title was just a name
when it came to Google though. Eric was the face, but I always felt he
and Larry were running things.
|
Mark M. |
oh, I agree
|
Mark M. |
OTOH, I think Larry is a better fit for the I|O crowd
|
Mark M. |
at least in terms of making an impression if he spoke
|
NetApex |
I don't think I have ever seen him speak
|
Mark M. |
he and Sergey did a brief thing at the G1 launch that I caught on Webcast
|
Jan 20 | 10:30 PM |
Mark M. |
otherwise, I haven't seen either of them, but I haven't exactly gone looking, either
|
NetApex |
oh wow, that was way back in the day
|
Mark M. |
oh yeah
|
NetApex |
ok, well no need to keep you any longer I suppose
|
Mark M. |
yeah, time to shut it down
|
Mark M. |
only one chat next week due to travel
|
NetApex |
have a good night man, and thanks for the tips. Alrighty
|
Mark M. |
have a pleasant evening!
|
NetApex |
You as well
|
NetApex | has left the room |
Mark M. | turned off guest access |