0

i am developing a web application that has a functionality to buy products from eCommerce web site through my app. the web view of a particular eCommerce product is shown.now how can i find if the user has clicked the buy button.is there any way to capture hyperlink click of a webpage .

example if in my web view i am showing a amazon's product page.how can i trace if the user clicks the buy link of the product page.

Dinesh Kannan
  • 1,255
  • 13
  • 32
  • shouldOverrideUrlLoading. http://stackoverflow.com/questions/16669046/android-webview-shouldoverrideurlloading-method – EpicPandaForce Mar 23 '15 at 13:24
  • @EpicPandaForce please correct me if am wrong.in the link you provided they are loading a known structured html (local web page)..in my case i don't know the id of link clicked by the user .. example – Dinesh Kannan Mar 23 '15 at 13:29
  • You have access to the whole URL. Debug it. – EpicPandaForce Mar 23 '15 at 13:36
  • if this is the url i am loading http://www.amazon.in/gp/product/B00R0BD9H8/ref=pd_luc_rh_cps_01_01_t_img_lh?ie=UTF8&psc=1 then how can find the event of clicking buy link – Dinesh Kannan Mar 23 '15 at 13:39

1 Answers1

0

try this way..

 TextView decription = (TextView)convertView.findViewById(R.id.library_rss_expan_chaild_des_textView);
String dec=d.get_description()+"<a href='"+d.get_link()+"'><u>more</u></a>";
CharSequence sequence = Html.fromHtml(dec);
SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
UnderlineSpan[] underlines = strBuilder.getSpans(0, 10, UnderlineSpan.class);   
for(UnderlineSpan span : underlines) {
int start = strBuilder.getSpanStart(span);
int end = strBuilder.getSpanEnd(span);
int flags = strBuilder.getSpanFlags(span);
ClickableSpan myActivityLauncher = new ClickableSpan() {
    public void onClick(View view) {
        Log.e(TAG, "on click");
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(d.get_link()));
        mContext.startActivity(intent);         
    }
};
strBuilder.setSpan(myActivityLauncher, start, end, flags);
}
decription.setText(strBuilder);
decription.setLinksClickable(true);
 decription.setMovementMethod(LinkMovementMethod.getInstance());