Relationship between Widget and main app?
I have a working app which reports a bunch of statistics. I am now wanting to include a couple of widgets that show some summary data so that the user doesn't have to open the app to get to it.
What's the relationship between widgets and apps? Can I reuse the main code or do I need to duplicate some of the code so that the widget can function independently?
The problem with widgets is that widgets can't be easily updated in real-time and here's why. Widget representation is generated by the application and then passed to launcher for display (this also answers your second question). To refresh the representation periodically you need to setup the timer. But timer handling and refreshing is power-consuming, so you can't set a timer to update the widget every second or so - it will burn the battery quickly.
HTC widgets are special as they have support from HTC Launcher, so they can be animated etc. .