I am developing a Cordova Android and iOS application. I am downloading multiple format of documents in my app like PDF and HTML.
I need to open these document from my app. Is there any way to call a default PDF application or other application that support the format of the document from my Cordova application?
I know that the final resolution is to write my own implementation to read the documents using 3rd party libraries.
UPDATE:(Another plugin option)
IF you have similar requirement. Have a look at
https://github.com/pwlin/cordova-plugin-file-opener2
This plugin supports both iOS and Android
If you have to try out with external FileOpener library then i think it will works.
Try this link :- https://github.com/markeeftb/FileOpener
Hope it will helps you.
You can achieve this in Android as follows:
Uri fileUri = Uri.fromFile(file);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(fileUri);
startActivity(intent);
If you are handling multiple file types, use Intent.setType
You can use MimeTypeMap.getMimeTypeFromExtension to get the type you need to set in the Intent.
Related
i need to show .pptx and .ppt file in android using third parties API or jar, if anyone found related to that, please guide me to read and view the .ppt files in android. i tried last one day for that but i cant.Even i tried Apache poi and some GitHub projects but i can't get the clear output.
Google Drive comes with an excellent document viewer, and you can simply send docs to it by intent. It renders all Office docs (so far as I have seen) quite well.
import android.support.v4.app.ShareCompat;
Uri pptUri = Uri.parse("file://sdcard/sdcard0/test.ppt");
Intent shareIntent = ShareCompat.IntentBuilder.from(this)
.setText("open ppt")
.setType("application/vnd.ms-powerpoint")
.setStream(pptUri )
.getIntent()
.setPackage("com.google.android.apps.docs");
startActivity(shareIntent);
And if you want to embed in your application a Third party lib : Refer this
MacOS X has PDFKit which in turn has PDFView. What other operating systems support viewing PDF files natively?
Android does not have a built-in PDF presenter. However, I found a workaround. Have a look at this thread. I extended the PdfViewerActivity in order to present a PDF file. It works pretty nice.
Snippet:
Intent intent = new Intent(CurrentActivity.this, ExtendedPdfViewerActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, pathToPdfDocument);
startActivity(intent);
We have a serious problem to tackle here. We are loading pdf documents as binaries into our application and need to be able to view them. Due to security reasons we are not allowed to store them on an external storage.
Our investigations showed that adobe reader x does not support handling binaries and can only digest physical links to a document. This means, it is not an option for us.
Is it correct that Google does not provide a native API to view PDF documents? We could not find any evidence.
Only option left is to implement either our own pdf viewer activity or integrating an existing library.
Are our findings correct? If so, could somebody point out a suggestion on how to proceed here? Are there any ressources available enabling us to implement our own viewer?
We are currently looking at using: http://code.google.com/p/apv/
You can use this: http://www.adobe.com/devnet/readermobile.html. RMSDK supports everything that Adobe Reader built on top of it supports. Though, I wonder why the security? Why can't you generate password protected PDFs or livecycle protected ones? What is there to stop people from stealing your 'binary' (PDF document).
Is it correct that Google does not provide a native API to view PDF documents?
Yes it is true
We could not find any evidence.
Run a search yourself
Are there any resources available enabling us to implement our own viewer?
Besides the one you've shown there is andpdf
You can try searching if there is an application supporting pdf viewing on the phone. Some phones like Nexus supports this.
Uri path = Uri.parse("android.resource://com.your.app/raw/pdfId");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
// no apps with pdf support, run your own
}
I know this question has been asked several times but I couldnt find one satisfying answer.My requirement is simple.just to open the pdf docs within my app(android).But I am not able to find a simple way of doing this.either its native c/c++ way or writing your own engine.But isnt there any simple API so that I can include it like a jar and view the pdf?
No. There is no API in the Android SDK to natively display PDF.
Solutions I can suggest:
-Use an external application:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
startActivity(intent);
-If your PDF document is accessible online, use the Google Docs Viewer to open your PDF in a WebView:
http://docs.google.com/viewer?url=http://mypdf.pdf
you can use native plugin to show the PDF within your app. try this apv
I am new to android programming, so i have a question regarding how to open any document such as .doc, .docx, .ppt, etc. in android. I also need to implement preview functionality, wherein the file should be downloaded temporarily and user can see the file opened just by a single click.
How does dropbox does this? Is there any intents available?
Can anybody help me out of this issue by some example or code?
Thanks.
Unlike iOS, Android itself does not support rendering .doc or .ppt files.
You are looking for a public intent that allows your app to reuse other apps' activities to display these document types. But this will only work for a phone that has an app installed that supports this Intent.
http://developer.android.com/guide/topics/intents/intents-filters.html
This may help: Android Launching an application chooser with appropriate list of applications