13
votes

I want to add link to my website "Check your email". If user is on mob version link should open mail app or email service url in browser if app is absent. For example user has [email protected]. Link should open gmail app or https://mail.google.com in browser if user has no gmail app. Maybe it's better to launch user preferred mail app instead of gmail.

Android

I found https://developer.chrome.com/multidevice/android/intents whith intent link intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end

It works fine but I can't understand how to do same thing with https://play.google.com/store/apps/details?id=com.google.android.gm&hl=ru or any other app

Also I found https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND to open mail app but intent://send#Intent;action=android.intent.action.SEND;end not works

Can anybody give me working url to open gmail app or default mail app?

iOs

Universal links https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12

Internet has many articles how to link your site with your app. But how can I start another app from my site?

2
I have no idea how to work in web programming but below are few links docs.adjust.com/en/universal-links/… dev.branch.io/getting-started/universal-app-links/support/ios/… raywenderlich.com/128948/universal-links-make-connection hope it helps. Mail app always support for universal links.Gagan_iOS
@Gagan_iOS can you give me universal link to open mail app? Simple link like open-mail-appDmitry Teplyakov

2 Answers

6
votes

One way to do this is to add a link in your website such as

<a href="mailto:[email protected]?Subject=Hello%20User">Inbox me!</a>

This will not work if you do not have any mail app installed on your Android phone. Therefore, you must install an app that can listen to this mail event/intent such as GMail. If two or more apps are installed that can handle this event/intent, Android will show a list of apps, asking you which app to use to open the link.

The next thing you wanna do is have your own Android app listed as one of the apps that can handle mail event/intent. This is where Receiving an Intent comes in. In your Manifest.xml, declare your activity as below:

<activity android:name="EmailHandlerActivity">
    <intent-filter>
        <action android:name="android.intent.action.SENDTO" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="mailto" />
    </intent-filter>
</activity>

Reference: https://developer.android.com/guide/components/intents-filters.html

UPDATE:

Here is another way to Open android application from a web page. But for this to work, you need to know specifically how the Mail app's inbox activity was declared in the Manifest.xml. If the activity was declared as below:

<activity android:name="InboxActivity">
    <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:scheme="my_scheme" android:host="my_host" />
    </intent-filter>
</activity>

You can should write your URL as

<a href="intent://my_host#Intent;scheme=my_scheme;action=android.intent.action.VIEW;end">
    Go to Mail!
</a>
0
votes

In my Android application, I try to redirect the link when we click on "Contact Us" option menu, we should go to the mail App.

Here is the syntax :

val viewIntent = Intent("android.intent.action.VIEW",
                 Uri.parse("mailto:[email protected]"))
startActivity(viewIntent)