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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…