I'm working on a ListView widget where I want the user to be able to launch a activity when the ListView is clicked. I haven't been able to find any sort of tutorial on this so I'm wondering if anyone could point me in the right direction or perhaps share some code. I want to launch the same activity regardless of which ListItem is clicked so that's not a problem.
All help is appreciated!
Have a look here and scroll to the subheading Adding behavior to individual items.
You need to make sure you call both
setPendingIntentTemplate()
from yourAppWidgetProvider
andsetOnClickFillInIntent()
from yourRemoteViewsService.RemoteViewsFactory
implementation.For example:
There is a more conclusive example in the StackWidget sample which is in the SDK samples, although I found it somewhat difficult to find (see here for directions). It creates an intent to show a Toast message, but it uses the same code.
To launch any Activity you create an Intent and then call startActivity on that intent. Check Intent and startActivity and I am sure you will able to do it yourself.