Spawn Android desktop widget from an application
I have an Android application does many things. I would like to be able have it spawn a desktop widget (?) that opens the application to do a specific thing when the widget is clicked.
Can someone give me a road map on how t开发者_如何学Co do this?
As far as i know, Android applications can not add App Widgets to the home screen. Applications can define App Widgets, but user has to add them manually to the home screen.
However it is not hard to launch Activitys from a widget using PendingIntent.
This is called AppWidget and is described in details in Android documentation (both references and step-by-step guide). Note, that it's the user that adds the widget to his launcher screen. AFAIK there's no way to add it to launcher in code (though HTC might have some undocumented ways).
精彩评论