Android Sending an email with html attachment -


my assetfiledescriptor.java class file:-

public class assetsprovider extends contentprovider { file file;  @override public assetfiledescriptor openassetfile(uri uri, string mode) throws filenotfoundexception {     system.out.println("assetsgetter: open asset file");     assetmanager = getcontext().getassets();     string file_name = uri.getlastpathsegment();     if (file_name == null)         throw new filenotfoundexception();     assetfiledescriptor afd = null;     try {         afd = am.openfd(file_name);     } catch (ioexception e) {         e.printstacktrace();     }     return afd;//super.openassetfile(uri, mode);   }  @override public string gettype(uri p1) {     // todo: implement method     return null; }  @override public int delete(uri p1, string p2, string[] p3) {     // todo: implement method     return 0; }  @override public cursor query(uri p1, string[] p2, string p3, string[] p4, string p5) {     // todo: implement method     return null; }  @override public cursor query(uri uri, string[] projection, string selection, string[] selectionargs, string sortorder, cancellationsignal cancellationsignal) {     // todo: implement method     return super.query(uri, projection, selection, selectionargs, sortorder, cancellationsignal); }  @override public uri insert(uri p1, contentvalues p2) {     // todo: implement method     return null; }  @override public boolean oncreate() {     // todo: implement method     return false; }  @override public int update(uri p1, contentvalues p2, string p3, string[] p4) {     // todo: implement method     return 0; } 

my mainactivity.java class file :-

public class mainactivity extends activity implements onclicklistener {  edittext edittextemail, edittextsubject, edittextmessage; button btnsend, btnattachment; string email, subject, message, attachmentfile; uri uri = null; private static final int pick_from_gallery = 101; int columnindex;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     edittextemail = (edittext) findviewbyid(r.id.edittextto);     edittextsubject = (edittext) findviewbyid(r.id.edittextsubject);     edittextmessage = (edittext) findviewbyid(r.id.edittextmessage);     btnattachment = (button) findviewbyid(r.id.buttonattachment);     btnsend = (button) findviewbyid(r.id.buttonsend);      btnsend.setonclicklistener(this);  }   @override public void onclick(view v) {      /*if (v == btnattachment) {         opengallery();      }*/     if (v == btnsend) {         try {             email = edittextemail.gettext().tostring();             subject = edittextsubject.gettext().tostring();             message = edittextmessage.gettext().tostring();             /// old code             final intent emailintent = new intent(android.content.intent.action_send);             emailintent.settype("file/html");             emailintent.setflags(intent.flag_activity_new_task);             emailintent.putextra(intent.extra_stream, uri.parse("content://com.example.deepa.xmlparsing/file:///android_assets/combination-1.html"));              startactivity(intent.createchooser(emailintent, "send email using"));             //old code           } catch (throwable t) {             toast.maketext(this,                     "request failed try again: " + t.tostring(),                     toast.length_long).show();         }     }  } } 

i getting file asset folder (combination-1.html).when trying. getting filenotfoundexception :-

java.io.filenotfoundexception: file can not opened file descriptor; compressed 05-15 11:38:23.467    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ android.content.res.assetmanager.openassetfd(native method) 05-15 11:38:23.467    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ android.content.res.assetmanager.openfd(assetmanager.java:332) 05-15 11:38:23.467    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ com.example.deepa.xmlparsing.assetsprovider.openassetfile(assetsprovider.java:30) 05-15 11:38:23.477    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ android.content.contentprovider.opentypedassetfile(contentprovider.java:1393) 05-15 11:38:23.477    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ android.content.contentprovider.opentypedassetfile(contentprovider.java:1459) 05-15 11:38:23.477    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ android.content.contentprovider$transport.opentypedassetfile(contentprovider.java:342) 05-15 11:38:23.477    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ android.content.contentprovidernative.ontransact(contentprovidernative.java:305) 05-15 11:38:23.477    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ android.os.binder.exectransact(binder.java:404) 05-15 11:38:23.477    2822-2834/com.example.deepa.xmlparsing w/system.err﹕ @ dalvik.system.nativestart.run(native method) 05-15 11:43:24.727    2822-2822/com.example.deepa.xmlparsing w/iinputconnectionwrapper﹕ showstatusicon on inactive inputconnection 05-15 11:45:35.417    3182-3182/com.example.deepa.xmlparsing d/dalvikvm﹕ late-enabling checkjni 05-15 11:45:35.577    3182-3182/com.example.deepa.xmlparsing d/libegl﹕ loaded /system/lib/egl/libegl_tegra.so 05-15 11:45:35.587    3182-3182/com.example.deepa.xmlparsing d/libegl﹕ loaded /system/lib/egl/libglesv1_cm_tegra.so 05-15 11:45:35.607    3182-3182/com.example.deepa.xmlparsing d/libegl﹕ loaded /system/lib/egl/libglesv2_tegra.so 05-15 11:45:35.637    3182-3182/com.example.deepa.xmlparsing d/openglrenderer﹕ enabling debug mode 0 

thank you.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -