> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/get-started/xamarin-android/view-android.md).

# Step 2: View a document in Xamarin.Android

Create a new Visual Studio Xamarin.Android project with Single View App, add Android permissions for DocumentActivity, and customize your document viewer for optimal performance. Follow Android best p

If you do not already have an existing application, create a new Visual Studio `Xamarin.Android` project with `Single View App`.

1. In order to support all the features in `DocumentActivity`, we will need to add the Android permissions listed in [this table](/xamarin/learn-more/permissions.md#android-permissions-list). However if you would like to disable certain features and customize your document viewer, you should leave out unnecessary permissions.

{% hint style="warning" %}
**Storage permission**

Please note that from Android 6.0 (API 23) and up, applications need to request storage permission at runtime before accessing any files on device.
{% endhint %}

1. Enable `largeHeap` and `usesClearTextTraffic`:

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

```xml
<!-- Enable usesCleartextTraffic in application attributes if you are working with HTTP files. If you are only working with HTTPS files, this is not required. -->
<application ... android:largeHeap="true" android:usesCleartextTraffic="false">
    ...
</application>
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**If your app is targeting Android SDK version 28 or higher, you will need to add the android:usesCleartextTraffic="true" attribute in your application tag to open HTTP files in the viewer. If you are only working with HTTPS files, this is not required.**
{% endhint %}

1. If you have not done so already, add the `<meta-data>` tag containing a reference to your license key in the `AndroidManifest.xml` file. Also, declare `DocumentActivity` in the same file. The final `AndroidManifest.xml` file should look something like this:

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <!-- Required permissions are added here -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <!-- Add multidex support, enable largeHeap, and enable usesCleartextTraffic. Also enable usesCleartextTraffic in application attributes if you are working with HTTP files. If you are only working with HTTPS files, this is not required. -->
    <application ... android:largeHeap="true" android:usesCleartextTraffic="true">    
        
        <!-- Add license key in meta-data tag here. This should be inside the application tag. -->
        <meta-data android:name="pdftron_license_key" android:value="INSERT_COMMERCIAL_LICENSE_KEY_HERE_AFTER_PURCHASE"/>
            
        <!-- Document viewer activity declaration-->
        <activity android:name="com.pdftron.pdf.controls.DocumentActivity" android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize" android:windowSoftInputMode="adjustPan" android:theme="@style/PDFTronAppTheme"/>
        ...
    </application>
</manifest>
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
\*\* Storage Permission \*\*

Please follow the latest Android best practices and guidelines outlined [here](https://developer.android.com/training/permissions/usage-notes/)
{% endhint %}

1. Add the following two lines at the end of the `OnCreate` method in `MainActivity.cs`:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
var config = new pdftron.PDF.Config.ViewerConfig.Builder().OpenUrlCachePath (this.CacheDir.AbsolutePath).Build();
var intent = DocumentActivity.IntentBuilder.FromActivityClass(this, Java.Lang.Class.FromType(typeof(DocumentActivity)))
      .WithUri(Android.Net.Uri.Parse("https://pdftron.s3.amazonaws.com/downloads/pdfref.pdf"))
      .UsingConfig(config)
      .Build();
StartActivity(intent);
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Note that using the cache is a temporary solution and you should request runtime permissions for external storage.
{% endhint %}

1. Build your project and deploy it to your Android Device/Emulator. You should see the viewer start up:

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-1a88d8639711be3240daca0d19e29b060249ad48%2Fc72b87ed29f9a9f51b8a9a93d5bdd8172e2fcfa2-1080x2220.png?alt=media)

## Next step

<a href="/xamarin/get-started/xamarin-android/customize-android.md" class="button primary">Customize</a><a href="/xamarin/get-started/faq/add-license.md" class="button primary">Add an Apryse license key</a>

{% hint style="info" %}
\*\* To view a document from other sources into DocumentActivity, check out this guide . \*\*
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/xamarin/get-started/xamarin-android/view-android.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
