On Wed, Sep 8, 2010 at 9:52 AM, Rich Allen <[email protected]> wrote: > Hi Mark, thank you for responding. I've looked through the code you > provided and I'm still a little unclear. I don't believe I need any of the > wakeful intent code, correct?
Probably not, in your case, since you said you didn't want the alarm to go off while the device was asleep. > My widget currently has a service with a function called "buildUpdate" that > returns a RemoteViews object. > To enable 5 minute updates, I need to: > - Add a new BroadcastReceiver class that overrides the onReceive function, > calls my "buildUpdate" function and updates my app widget. > - Add code to the onStart function of my service that creates the > AlarmManager intent and starts it up. > > Is this even close? Well, it's in the ballpark, at least. Depending on how long buildUpdate() takes, you may wish to consider delegating that work to an IntentService -- onReceive() is called with foreground priority on the main application thread, so you really want it to be snappy. Whether onStart() is the right place/time to set up your AlarmManager is difficult for me to say, since I don't know your app. > By the way, I have your book "Beginning Android 2" and another book on > Android development and neither one has much coverage of App Widgets, if any > at all. Resources on the net are also very sparse regarding App Widgets. > For me, obviously, this is the area where I felt I needed to write my own > application, so I'm curious about the apparent lack of information > available. The few tutorials available all basically say "The 1.6 update > broke this. Sorry." Here we are at the start of 2.2 and there's nothing? > Or am I missing some valuable resources somewhere? :) I'm not sure what constitutes "valuable", but: http://commonsware.com/AdvAndroid/ I would assume some of the other newer/bigger books cover app widgets as well, though I haven't gone looking. But my app widget and AlarmManager coverage is in one of my books, just not the one you have. My apologies. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in London: http://skillsmatter.com/go/os-mobile-server -- 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

