Want to open downloaded file in appropriate application in Android -
i have download document server, app , save private folder.
the document can .doc, .pdf, .docs, .jpg
etc.
now, want is, after download completed, show alert dialog
open document.
when click on pen button open particular file in appropriate application , if app not available, show dialog
download app.
give me hint on this.
thanks in advance.
try way:
mails attachment open
file file = new file(yourdownloadfilepath); if ((download_file_name.endswith(".pdf")) || (download_file_name.endswith(".pdf"))){ if(file.exists() && file.length()!=0){ intent intent = new intent(); intent.setclassname("com.adobe.reader","com.adobe.reader.adobereader"); intent.setaction(android.content.intent.action_view); intent.setflags(intent.flag_activity_clear_top); uri uri = uri.fromfile(file); intent.setdataandtype(uri, "application/pdf"); try { startactivity(intent); } catch (exception e) { alertdialog.builder builder = new alertdialog.builder(youractivity.this); builder.settitle("no application found"); builder.setmessage("download application android market?"); builder.setpositivebutton( "yes, please", new dialoginterface.onclicklistener() { @override public void onclick( dialoginterface dialog, int which) { intent marketintent = new intent( intent.action_view); marketintent.setdata(uri .parse("market://details?id=com.adobe.reader")); startactivity(marketintent); } }); builder.setnegativebutton("no, thanks", null); builder.create().show(); } } } else if ((download_file_name.endswith(".jpg"))|| (download_file_name.endswith(".bmp"))|| (download_file_name.endswith(".bmp"))||(download_file_name.endswith(".png"))|| (download_file_name.endswith(".png"))||(download_file_name.endswith(".gif"))|| (download_file_name.endswith(".gif"))|| (download_file_name.endswith(".jpg"))) { intent intent = new intent(); intent.setaction(android.content.intent.action_view); intent.setdataandtype(uri.fromfile(file), "image/*"); startactivity(intent); } else if ((download_file_name.endswith(".txt"))) { intent intent = new intent(); intent.setaction(android.content.intent.action_view); intent.setdataandtype(uri.fromfile(file), "text/html"); startactivity(intent); }
Comments
Post a Comment