2026-07-15

How to open an installed app from an email URL in Android?

Stefan Bogdanescu

Stefan Bogdanescu

Founder & Senior Architect

How to open an installed app from an email URL in Android?

How to Open an Installed App from an Email URL in Android: Mastering Deep Linking

As developers, one of the most common requirements today is bridging the gap between external links (like those found in emails or web pages) and launching a specific installed application. This process is known as Deep Linking, and it’s crucial for creating seamless user experiences. While your initial attempt with the intent-filter was close, achieving reliable deep linking requires understanding the Android Intent system deeply.

This post will walk you through the correct, robust method for handling external URLs from an email context and launching the corresponding application on Android.


Understanding Android Intents and Deep Linking

Android uses Intents as the messaging system to request an action from another application component. When you click a link, the operating system needs to know which app should handle that specific URL or data. This is where the Intent object comes into play.

To make your application discoverable by external links (like those in emails), you must define specific Intent Filters within your AndroidManifest.xml. These filters act as declarations, telling the Android system: "If a link matches this pattern (e.g., twitter.com), my Activity is capable of handling it."

The Difference Between Web Links and App Launches

The example you provided focuses on launching an app via a web URL (http://www.twitter.com). While this works for opening the web browser, deep linking to other installed apps requires specific configuration. For true deep linking (launching the Twitter application itself), we focus on defining the necessary data schemes and ensuring your app can handle that input.

Step-by-Step Implementation Guide

To successfully open an app from a URL, you need to manage two main components: declaring capability and handling the incoming request.

Step 1: Configure the AndroidManifest.xml (The Intent Filter)

You must register an <intent-filter> that specifies which URLs or data types your application can handle. This filter should be placed on the Activity that is responsible for receiving the link.

For an app designed to handle Twitter links, you would define the following in your AndroidManifest.xml:

<activity android:name=".MainActivity">
    <intent-filter>
        <!-- Action to indicate we can handle a VIEW request -->
        <action android:name="android.intent.action.VIEW" />
        
        <!-- Category indicating this activity can handle general content -->
        <category android:name="android.intent.category.DEFAULT" />
        
        <!-- Crucially, define the data scheme and host you want to intercept -->
        <data android:scheme="twitter" android:host="www.twitter.com" />
    </intent-filter>
</activity>

Developer Insight: Notice how we defined a custom scheme (twitter) instead of relying solely on http. This makes your deep link specific and prevents accidental interception by other web applications, making the intent handling much cleaner.

Step 2: Handling the Intent in Your Activity (Kotlin Example)

Once the system routes the email link to your application, the onCreate() method receives an Intent object. You need to extract the URI data from this Intent and use it to launch the correct component or navigate within your app.

import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Check if an Intent was passed to this activity
        val intent = intent

        if (intent != null && intent.action == Intent.ACTION_VIEW) {
            // Extract the data (the URL) from the Intent
            val data: Uri? = intent.data

            if (data != null) {
                // Example: Use the extracted URI to open the link or launch a specific screen.
                val url = data.toString() 
                
                // In a real scenario, you would parse this URL and navigate:
                // handleDeepLink(url)
                println("Received Deep Link: $url")

                // If you want to explicitly open the link using an external browser (less common for deep linking):
                // val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
                // startActivity(browserIntent)
            }
        }
    }
}

Connecting Deep Linking to Backend Architecture

Handling complex routing and data management, especially when dealing with external service integrations like email parsing or URL management, often benefits from a robust backend structure. Frameworks like Laravel provide excellent tools for managing these relationships and ensuring data integrity across your application flow. When designing services that handle external links and user sessions, having a well-structured API layer, as promoted by frameworks like Laravel, ensures that the logic for opening an app is decoupled from the presentation layer. This separation makes your code cleaner, more testable, and easier to maintain as your application grows in complexity.

Conclusion

Opening an installed app from an email URL in Android is achieved not just by defining an intent-filter, but by correctly setting up a structured communication channel using Intents, defining specific data schemes, and meticulously parsing the incoming data within your Activity. By mastering these concepts, you transition from simply handling clicks to building sophisticated, seamless user journeys.

Tags:

Enhance your marketing setup with your own email marketing platform.

Join the growing number of SaaS platforms using Laravel Mail to offer email marketing solutions to their customers.