How to open/display documents(.pdf, .doc) without external app?
I think you should use custom library for getting that done .See this and this
But there is a way for displaying PDF with out calling another application
This is a way for showing PDF in android app that is embedding the PDF document to android webview using support from http://docs.google.com/viewer
pseudo
String doc="<iframe src='http://docs.google.com/viewer?url=+location to your PDF File+'
width='100%' height='100%'
style='border: none;'></iframe>";
a sample is is shown below
String doc="<iframe src='http://docs.google.com/viewer?url=http://www.iasted.org/conferences/formatting/presentations-tips.ppt&embedded=true'
width='100%' height='100%'
style='border: none;'></iframe>";
Code
WebView wv = (WebView)findViewById(R.id.webView);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setPluginsEnabled(true);
wv.getSettings().setAllowFileAccess(true);
wv.loadUrl(doc);
//wv.loadData( doc, "text/html", "UTF-8");
and in manifest provide
<uses-permission android:name="android.permission.INTERNET"/>
See this
Caution : I am not aware of compatibility issues with various android versions
In this approach the drawback is you need internet connectivity . But i think it satisfy your need
EDIT
Try this as src for iframe
src="http://docs.google.com/gview?embedded=true&url=http://www.pc-hardware.hu/PDF/konfig.pdf"
try wv.loadData( doc , "text/html", "UTF-8");
. Both works for me
How open document pdf/docx with external app in Android
Try the below code :
File pdfFile = new File("File Path");
Intent openPdf = new Intent(Intent.ACTION_VIEW);
openPdf.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
fileUri = FileProvider.getUriForFile(viewContext,com.mydomain.fileprovider, pdfFile);
openPdf.setDataAndType(fileUri, "application/pdf");
openPdf.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(openPdf, "Select Application"));
Note : You need File Provider for granting URI permissions check this out
how to display online pdf file within app
It seems that library doesn't allow to display remote files.
Check this issue: Library does not support remote files, you have to download it by yourself.
You should download and store that PDF locally before trying to display it.
Display Word/PDF Document inside my Android Application
open pdf/Doc in webview
String pdf = "http://www.pc-hardware.hu/PDF/konfig.pdf";
String doc="<iframe src='http://docs.google.com/viewer?url=http://www.iasted.org/conferences/formatting/presentations-tips.ppt&embedded=true'
width='100%' height='100%'
style='border: none;'></iframe>";
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.loadUrl(doc);
Display PDF file inside my android application
Maybe you can integrate MuPdf in your application. Here is I've described how to do this: Integrate MuPDF Reader in an app
Android : how to open pdf file from server in android
you have to try this code for open a pdf file in your application..
WebView webView = (WebView) findViewById(R.id.my_webview);
webView.setWebViewClient(new MyWebViewClient());
webView.addView(webView.getZoomControls());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://docs.google.com/gview?embedded=true&url=http://myurl.com/demo.pdf");
Related Topics
Use Camera Flashlight in Android
Failed Binder Transaction When Putting an Bitmap Dynamically in a Widget
Dynamic Listview Adding "Load More Items" at the End of Scroll
Android Compass That Can Compensate for Tilt and Pitch
New Intent() Starts New Instance with Android: Launchmode="Singletop"
Actionbarsherlock + Tabs + Multi Fragments
How to Make My Android App Appear in the Share List of Another Specific App
How to Put Media Controller Button on Notification Bar
Location Needs to Be Enabled for Bluetooth Low Energy Scanning on Android 6.0
Device Not Detected in Eclipse When Connected with Usb Cable
Android - Getting Audio to Play Through Earpiece
Creating a Directory in /Sdcard Fails
Android Take Screen Shot Programmatically
Gradle's Dependency Cache May Be Corrupt (This Sometimes Occurs After a Network Connection Timeout.)
Handling a Menu Item Click Event - Android
How to Create a Resizable Rectangle with User Touch Events on Android
How to Use Getsystemservice in a Non-Activity Class (Locationmanager)