Open PDF-File in Android not working -


i try open pdf file apps directory through pdf viewer on device.

packagemanager m = getpackagemanager(); string s = getpackagename();                 packageinfo p;                 try {                     p = m.getpackageinfo(s, 0);                      s = p.applicationinfo.datadir;                 } catch (namenotfoundexception e) {                                          log.w("error", "error package not found ", e);                                      }                  intent intent = new intent(intent.action_view, uri.parse(s + "\\document.pdf")); intent.settype("application/pdf");                   packagemanager pm = getpackagemanager();                     intent crc = intent.createchooser(intent, "open file"); startactivity(crc); 

on test device pdf viewer installed. nevertheless i'm told no existing app able open file. doing wrong?

if still interested, here solution:

i changed code this:

intent intent = new intent(intent.action_view, uri.parse(s + "\\document.pdf")); intent.settype("application/pdf");  

to this:

intent intent = new intent(intent.action_view); intent.setdataandtype(uri.parse(s + "\\document.pdf"), "application/pdf");  

and worked. :)


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -