WebViewGold Documentation · Android
🇺🇸 English
Get WebViewGold

ShareIntent API

Receive content shared from other Android apps directly in your WebView app via Share Intents.

The WebViewGold ShareIntent API enables your app to appear as a target in Android’s native Share dialog. This allows users to share content such as text, URLs, or images (as base64 strings) from any other app directly into your WebView-based app.

Use Cases:

  • Sharing links to user profiles, notes, or articles directly into your app
  • Receiving content from messaging or browser apps
  • Sending images from the gallery to your WebView interface (base64-encoded)

Step 1: Enable Sharing Support in AndroidManifest.xml

To allow your app to receive shared data, uncomment the relevant intent filters in your AndroidManifest.xml file:

<!-- Receive shared text (e.g., URLs or notes) -->
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

<!-- Receive a single shared image -->
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>

<!-- Receive multiple shared images -->
<intent-filter>
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>

Once these filters are active, your WebViewGold-based app icon will appear as a sharing target whenever users share content from another app.

Step 2: Handle Shared Data in Your WebView

When a user shares content to your app, WebViewGold will automatically inject the shared content into a JavaScript variable named sharedData.

<script>
    alert(sharedData); // Displays the shared content (text or base64 image)
</script>
  • Text or URL: Will be passed as plain text into sharedData
  • Image: Will be converted to a base64-encoded string and passed into sharedData

Example Use: Automatically populate a form or preview an image based on the received content:

<script>
    if (sharedData) {
        document.getElementById("myInput").value = sharedData;
    }
</script>

Note: Ensure that your JavaScript is ready to handle both plain text and long base64 strings. You may also implement client-side checks to distinguish between different content types.

Too busy? We set up your app for you.

Our team configures, builds & submits your WebViewGold app — done-for-you, fast turnaround, Made in Germany.

Get your app set up →

Build in your browser

No Mac, no IDE: the WebViewGold Cloud Builder configures, builds & uploads your app online.

Discover Cloud Builder →