clickable links in textview

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

clickable links in textview

Postby zet » Sun Mar 29, 2009 12:47 pm

Hi,
i made autodetection of url links in textview object by
setAutoLinkMask(Linkify.ALL)

but, when i click on the link, then execption happens:
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

maybe because textview try to start browser and does not add that flag to startActivity method, can it be fixed?

thanks,
zet
zet
Freshman
Freshman
 
Posts: 4
Joined: Fri Mar 27, 2009 9:49 pm

Top

Postby zet » Mon Mar 30, 2009 3:27 am

i will answer myself again :)

i found a solution, in application context i have to override method startActivity, so when UrlSpan from TextView calls startActivity it does this code instead of default:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         @Override
  3.  
  4.         public void startActivity(Intent intent)
  5.  
  6.         {
  7.  
  8.                 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  9.  
  10.                 super.startActivity(intent);
  11.  
  12.         }
  13.  
  14.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
zet
Freshman
Freshman
 
Posts: 4
Joined: Fri Mar 27, 2009 9:49 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests