android - sendEmail method in dynamically created button? -


i dynamically created buttons , want send email clicking on these buttons, goes wrong. nothing happens. :( please me, beginner.

adapterlistingorders:

public class adapterlistingorders extends appcompatactivity {  private button btnaccrejorders;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.adapter_listing_orders);      toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);      btnaccrejorders = (button) findviewbyid(r.id.order_acc_rej);      btnaccrejorders.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             log.i("send email", "");             string[] = {""};             string[] cc = {""};             intent emailintent = new intent(intent.action_send);              emailintent.setdata(uri.parse("mailto:"));             emailintent.settype("text/plain");             emailintent.putextra(intent.extra_email, to);             emailintent.putextra(intent.extra_cc, cc);             emailintent.putextra(intent.extra_subject, "your subject");             emailintent.putextra(intent.extra_text, "email message goes here");         }     }); } } 

but onclick not work. when press btnaccrejorders, logcat display:

viewpostimeinputstage processpointer 0 viewpostimeinputstage processpointer 1 

btnaccrejorders.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             log.i("send email", "");             intent = new intent(intent.action_send);             i.settype("message/rfc822");             i.putextra(intent.extra_email  , new string[]{"recipient@example.com"});             i.putextra(intent.extra_subject, "subject of email");             i.putextra(intent.extra_text   , "body of email");             try {                     startactivity(intent.createchooser(i, "send mail..."));                 } catch (android.content.activitynotfoundexception ex) {                 toast.maketext(myactivity.this, "there no email clients installed.", toast.length_short).show();                 }         }     }); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -