We can add user interactions in Activities but when it comes to a screen widget it is very difficult to do more things as it gives you very limited access to widgets. So have you ever think about adding buttons in scree widgets and make it more interactive. If you try this then you will probably come to know that , you can't do this directly in AppwidgetProvider class.
But still you can do this in a different way using pendingIntent. So place all interactions in another activity and make it as a pendingIntent. Then only thing left is pass the data from Appwidgetprovider class to this pendingIntent class and get results back on click of the buttons in screen widget. To do this you can use onClickPendingIntent method on remoview object.
You can get the complete example here in this link
Handling User Interaction with Android App Widgets - Developer.com
You can download the complete source code of Widget development tutorial source codes at
http://code.google.com/p/android-widget-development-tutorials/
No comments:
Post a Comment