开发者

Structure for a widget code

What classes would I need for a simple widget to do the following:

  1. Display on a home screen and run some code when it is clicked
  2. Run some code and update the widget at a specific time every day
  3. Run some code and update the widget when an SMS is received

I currently have a Receiver which extends AppWidgetProvider, and another Receiv开发者_StackOverflower which is called when a SMS is received. How should this program be structured? Is it possible to have all the code in one place, or does it have to be in separate classes?

Thanks for any help,

-Frink


If it is a small project you can have all in the same class. You just have to register the braodcasts in the AndroidManifest. If the proeject is larger doing everything in a huge class is not wise.

you just need to do a switch case or something like this in the onReceive method.


Not sure if you haven't read the book yet but "Android Application Development For Dummies" has a pretty good section on how to create a feature rich application and widget with notifications. I'm still reading it so I can't really answer your question but this book should help somewhat.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜