I would like to know how can I create a ‘dynamic intent’ in android.
In sum, what I want to accomplish is to show a list of items of data that are being fecthed from a webservice and when an item is clicked to launch a new activity with some parameters set. Note that all the items would be an instance of the same class, that I suppose would extend Activiy.
I have managed to list the items, but can’t seem to find a way to do the ‘dynamic intent’ part.
I know the following code doesn’t work, but it ilustrates what I am trying to accomplish.
Hope I have made myself understood.
if (((TextView) view).getText().equals("Page"))
{
MyClass item = new MyClass("foo", "bar");
myIntent = new Intent(view.getContext(), item);
}
Thanks.
You can send any custom or ‘dynamic’ content through the extras on the intent. These are available to the activity that is launched by the intent.
so you would do something like:
on the intent that you launch.
In your receiving activity you would do something like: