Android open .docx file via ContentResolver in QuickOffice crashes -
for reason code opening downloaded file, , in instance .docx not work quickoffice, exception i'm getting this:
06-02 22:04:05.356: e/androidruntime(2889): fatal exception: main 06-02 22:04:05.356: e/androidruntime(2889): process: com.quickoffice.android, pid: 2889 06-02 22:04:05.356: e/androidruntime(2889): java.lang.nullpointerexception 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.quickoffice.a.g.a(abstractsaveaction.java:14) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.d.a(abstractmenuitemcontroller.java:28) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.c.a(abstractbuttonmenuitemcontroller.java:24) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.y.a(menucontroller.java:59) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.y.a(menucontroller.java:59) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.z.run(menucontroller.java:37)
my code establishing intent is:
intent install = new intent(intent.action_view); string mimetype = getmimetype(tempfile); uri uri = uri.parse("content://com.companyname/"+ filename); install.setdataandtype(uri, mimetype); install.setflags(intent.flag_activity_no_history); intent intent = intent.createchooser(install, "open file"); _progressdialog.getcontext().startactivity(intent);
my content provider code is:
public class downloadedfilecontentprovider extends contentprovider { @override public parcelfiledescriptor openfile(uri uri, string mode) throws filenotfoundexception { file privatefile = new file(getcontext().getcachedir(), uri.getpath()); return parcelfiledescriptor.open(privatefile, parcelfiledescriptor.mode_read_write); } //other overridden methods return false , null contentprovider class. }
i'm out of ideas, case microsoft office on android, document doesn't open @ all. office suite application opens everything.
i did below
file file = new file(filepath); intent intent = new intent(intent.action_view); mimetypemap mimetypemap = mimetypemap.getsingleton(); string fileextension = filepath.substring(filepath.lastindexof(".") + 1); fileextension = fileextension.tolowercase(); if(mimetypemap.getmimetypefromextension(fileextension) != null) { string type = mimetypemap.getmimetypefromextension(fileextension); if(istablet(activity)) { if(fileextension.equals("txt")) { intent.setdataandtype(uri.fromfile(file), "text/plain"); //changed uri.parse(fp, type) method } else { intent.setdataandtype(uri.fromfile(file), type); } } else { intent.setdataandtype(uri.fromfile(file), type); } try{ activity.startactivityforresult(intent, constants.request_authentication_completed); }catch(android.content.activitynotfoundexception e){ system.out.println("exception : "+e.getlocalizedmessage()); } }
Comments
Post a Comment