I have implemented a
ListView in my Android application. I bind to this
ListView using a custom subclass of the
ArrayAdapter class. Inside the overridden
ArrayAdapter.getView(...) method, I assign an
OnClickListener. In the
onClick method of the
OnClickListener, I want to launch a new activity. I get the exception:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
How can I get the
Context that the
Activity) is working under?
Or as a last resort,
Edit - i would avoid setting flags as it will interfere with normal flow of event and history stack.
You can achieve it with addFlags instead of
According to the documentation it does:
Add additional flags to the intent (or with existing flags value).
Be aware if you are using flags that you change the history stack as Alex Volovoy's answer says:
...avoid setting flags as it will interfere with normal flow of event and history stack.