Pull
Pull

Reputation: 2246

How to open an app from a link in an email on Android?

If I call "myapp://" from Safari, it open correctly my app.

I used the URL Scheme and it works perfectly, here is the tutorial I followed : URL Scheme

Now I would like to open my app from an email. On Gmail for example, you can only send an hyperlink if this one can't handle http/https/www. If I send an hyperlink with "myapp://", the hyperlink is automatically suppressed.

I cannot call a dummy web page that would redirect to "myapp://" because any webpage on my server needs an authentication.

I just wanted to know if there is no other possibilities yet to open a Mobile Application from an email without having to call a webpage first ?

Upvotes: 1

Views: 5855

Answers (1)

Yash Sampat
Yash Sampat

Reputation: 30611

You have to add the scheme & host of the Uri to the intent-filter of your app's launch Activity in the manifest:

<activity
    android:name="com.somedomain.MainActivity"
    android:label="@string/app_name" >

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="myappuri.com"
            android:scheme="https" />

    </intent-filter>

</activity>

Now when you supply a Uri in the email as https://myappuri.com, it will implicitly open your app (or rather open a list of apps to choose from that includes your app).

References:

1. Allowing Other Apps to Start Your Activity.

2. <data>.

Upvotes: 4

Related Questions