0

I have a listview where every single element of the list has a textview. This textview has following properties:

chatText.setMovementMethod(LinkMovementMethod.getInstance()); Linkify.addLinks(chatText, Linkify.ALL);

now all links are appearing properly but when i click on them the app is force stopping and displaying following errors:

android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

how to solve this error??

Bojan Kseneman
  • 15,488
  • 2
  • 54
  • 59
manav patadia
  • 81
  • 1
  • 7

2 Answers2

0

You are probably using incorrect context, use the context of your activity.

Bojan Kseneman
  • 15,488
  • 2
  • 54
  • 59
0

You need to add this flag

FLAG_ACTIVITY_NEW_TASK before calling your startActivity()

to your intent.

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39
  • When you Linkify text, it does not expose the intent. You need to provide a method to do that before attempting to modify it. – Abandoned Cart Apr 16 '18 at 09:58