android - Open Link When Clicked on CardView -


my app uses asynctask fetch data webapi , displays them in recycler view.

what intend open corresponding link when clicked on card view in browser installed on phone.

i tried solutions mentioned app seems crash.

if use sendbroadcast instead doesn't anything.

my code recycler view adapter :

@override public void onbindviewholder(viewholder holder, int position) {     final news news = listnews.get(position);      holder.tvtitle.settext(news.gettitle());     holder.tvdesc.settext(news.getdescription());      picasso.with(getcontext()).load(news.geturltoimage()).into(holder.ivnews);     holder.newslayout.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             intent intent = new intent(intent.action_view, uri.parse(news.geturl()));             context.startactivity(intent);         }     }); } 

the app works fine , loads news items when click on news item crashes stopped responding message.

you should add line intent.addflags(intent.flag_activity_new_task);

like below :-

@override     public void onclick(view view) {         intent intent = new intent(intent.action_view, uri.parse(news.geturl()));         intent.addflags(intent.flag_activity_new_task);         context.startactivity(intent);     } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -