title: How to open new another activity using ClickableSpan
body: <p>I want to open new activite using <code>startActivity(new Intent(context, MyProfile.class));</code> when user clike on textview with # or @</p>
  
  <p>here is my code</p>
  
  <pre><code>    class CalloutLinkProfile extends ClickableSpan {
  
      Context context;
      TextPaint textPaint;
  
      public CalloutLinkProfile(Context ctx) {
          super();
          context = ctx;
  
      }
  
  
      @Override
      public void updateDrawState(TextPaint ds) {
          textPaint = ds;
         // ds.setColor(0xff336699);
  
          ds.setARGB(255, 30, 144, 255);
          ds.setTypeface(Typeface.DEFAULT_BOLD);
          ds.setUnderlineText(false); // set to false to remove underline
      }
  
      @Override
      public void onClick(View widget) {
          TextView tv = (TextView) widget;
          Spanned s = (Spanned) tv.getText();
          int start = s.getSpanStart(this);
          int end = s.getSpanEnd(this);
          String theWord = s.subSequence(start + 1, end).toString();
          Toast.makeText(context, String.format("Here's a cool user: %s", theWord), 10).show();
          startActivity(new Intent(context, MyProfile.class));
  
      }
  </code></pre>
  
  <p>here is my complete code</p>
  
  <pre><code>public class FeedHomeAdapter extends BaseAdapter {
  private Context mContext;
  private ArrayList&lt;String&gt; id;
  private ArrayList&lt;String&gt; puName;
  private ArrayList&lt;String&gt; pfName;
  
  private SQLiteDatabase dataBaseall;
  
  
  
  public FeedHomeAdapter(Context c, ArrayList&lt;String&gt; id, ArrayList&lt;String&gt; uname,
  
                         ArrayList&lt;String&gt; sid, ArrayList&lt;String&gt; svideo, ArrayList&lt;String&gt; isfollow, ArrayList&lt;String&gt; ischat) {
      this.mContext = c;
  
      this.id = id;
      this.puName = uname;
  
      this.isfollowing = isfollow;
      this.pischat = ischat;
  
  }
  
  public int getCount() {
      // TODO Auto-generated method stub
      return id.size();
  }
  
  public Object getItem(int position) {
      // TODO Auto-generated method stub
      return null;
  }
  
  public long getItemId(int position) {
  
      // TODO Auto-generated method stub
      return position;
  }
  
  public ArrayList&lt;int[]&gt; getSpans(String body, char prefix) {
      ArrayList&lt;int[]&gt; spans = new ArrayList&lt;int[]&gt;();
  
      Pattern pattern = Pattern.compile(prefix + "\\w+");
      Matcher matcher = pattern.matcher(body);
  
      // Check all occurrences
      while (matcher.find()) {
          int[] currentSpan = new int[2];
          currentSpan[0] = matcher.start();
          currentSpan[1] = matcher.end();
          spans.add(currentSpan);
      }
  
      return spans;
  }
  
  public View getView(final int pos, View child, ViewGroup parent) {
      final Holder mHolder;
      if (child == null) {
          child = LayoutInflater.from(mContext).inflate(R.layout.chat_display_item, parent, false);
          LayoutInflater layoutInflater;
          layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          child = layoutInflater.inflate(R.layout.card_layout, null);
  
          mHolder = new Holder();
          mHolder.txt_uName = (TextView) child.findViewById(R.id.name);
          mHolder.txt_uName1 = (TextView) child.findViewById(R.id.name1);
          mHolder.txt_fName = (TextView) child.findViewById(R.id.fname);
          mHolder.txt_satus = (TextView) child.findViewById(R.id.note);
  
  
          mHolder.comment = (ImageButton) child.findViewById(R.id.replide);
  
          child.setTag(mHolder);
  
      } else {
          mHolder = (Holder) child.getTag();
      }
      mHolder.txt_satus.setHighlightColor(Color.WHITE);
      mHolder.txt_satus.setHighlightColor(Color.TRANSPARENT);
  
  
  
      ArrayList&lt;int[]&gt; hashtagSpans = getSpans(psatus.get(pos), '#');
      ArrayList&lt;int[]&gt; calloutSpans = getSpans(psatus.get(pos), '@');
  
      SpannableString commentsContent =
              new SpannableString(this.psatus.get(pos));
  
      for (int i = 0; i &lt; hashtagSpans.size(); i++) {
          int[] span = hashtagSpans.get(i);
          int hashTagStart = span[0];
          int hashTagEnd = span[1];
  
          commentsContent.setSpan(new Hashtag(mContext),
                  hashTagStart,
                  hashTagEnd, 0);
  
      }
      for (int i = 0; i &lt; calloutSpans.size(); i++) {
          int[] span = calloutSpans.get(i);
          int calloutStart = span[0];
          int calloutEnd = span[1];
  
          commentsContent.setSpan(new CalloutLinkProfile(mContext),
                  calloutStart,
                  calloutEnd, 0);
  
      }
  
  
  
      mHolder.txt_satus.setMovementMethod(LinkMovementMethod.getInstance());
      mHolder.txt_satus.setText(commentsContent);
  
      mHolder.txt_linktext.setText(statuslinktext.get(pos));
      mHolder.txt_time.setText(ptime.get(pos));
  
  
  
  
  
  
  
  
      return child;
  }
  
  
  public class Holder {
      TextView txt_id;
      TextView txt_satus;
      TextView txt_time;
      TextView txt_uName;
      TextView txt_uName1;
  
      LinearLayout error_d;
      RelativeLayout profile_view;
  
  
  }
  
  
  // to check if app is install
  private boolean appInstalledOrNot(String uri) {
      PackageManager pm = mContext.getPackageManager();
      boolean app_installed = false;
      try {
          pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
          app_installed = true;
      } catch (PackageManager.NameNotFoundException e) {
          app_installed = false;
      }
      return app_installed;
  }
  
  
  
  
  
  
  
  class CalloutLinkProfile extends ClickableSpan {
  
      Context context;
      TextPaint textPaint;
  
      public CalloutLinkProfile(Context ctx) {
          super();
          context = ctx;
  
      }
  
  
      @Override
      public void updateDrawState(TextPaint ds) {
          textPaint = ds;
         // ds.setColor(0xff336699);
  
          ds.setARGB(255, 30, 144, 255);
          ds.setTypeface(Typeface.DEFAULT_BOLD);
          ds.setUnderlineText(false); // set to false to remove underline
      }
  
      @Override
      public void onClick(View widget) {
          TextView tv = (TextView) widget;
          Spanned s = (Spanned) tv.getText();
          int start = s.getSpanStart(this);
          int end = s.getSpanEnd(this);
          String theWord = s.subSequence(start + 1, end).toString();
          Toast.makeText(context, String.format("Here's a cool user: %s", theWord), 10).show();
          startActivity(new Intent(context, MyProfile.class));
  
      }
  
  
  
  }
  </code></pre>
  
  <p>}</p>