This section will show you how to open a document in a DocumentActivity. This is an AppCompatActivity which contains a PdfViewCtrlTabHostFragment2 and packages all the standard features used during document viewing. You can learn more in our document viewer overview.
AndroidManifest.xml file needs to be updated to request permissions to allow DocumentActivity to function properly. You also need to add some attributes to the <application> tag as well as a new <activity> tag to define the DocumentActivity. For more, see detailed description of permission requirements.Please follow the latest Android best practices and guidelines.
If your app targets Android SDK version 28 or higher, add the android:usesCleartextTraffic="true" attribute in your application tag to open HTTP files in the viewer. If you're only working with HTTPS files, this is not required.
2. Import the following in your MainActivity.java file.
3. Inside the onCreate method for your MainActivity class, add the following lines to open a demo PDF from a URL. You can open documents using DocumentActivity in many ways.
If you require more customizability options, please use PdfViewCtrlTabHostFragment2 since it gives you full control over UI and behavior customization. Read more on the different components in the viewer overview guide for Andriod .
Your app should look something like this:

You can explore the features of the viewer and also many customization options.
DocumentActivity can open documents from various resources including internal storage, URIs, web servers and the application's res folder.
You can open files from the these sources using the code below:
If you did not request Storage permission, the app sandbox is recommended for cache path, otherwise you have control over where you would like to store the cache file.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales