Launching Android Application from link or email

爱⌒轻易说出口 提交于 2019-11-27 02:54:17

问题


I have been trying to launch the application from a link on email or from a posting on some social networking websites. The problem is that in some device or some gmail application on the android don't show the anchor tags or link that I have specified.

The intent-filter that I set to my activity is below:

 <action android:name="android.intent.action.VIEW" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.BROWSABLE" />
 <data android:scheme="myappname" />

And I am sending the email with this anchor tag

myappname://processtobedone/?id=1

It works fine with the email application that I have on Huawei device but in device's default gmail application it is not showing it has an link and in some devices by default it appends https: as suffix for the tag and launches the browser.


回答1:


Instead of using a custom scheme, you can have an <intent-filter> that identifies a URL that you control:

<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="www.this-so-does-not-exist.com"
        android:path="/something"
        android:scheme="http"/>
</intent-filter>

Then, links to http://www.this-so-does-not-exist.com/something will bring up your app (in a chooser, along with the Web browse) on devices that have your app, and will bring up your Web page on devices that do not have your app.




回答2:


Make a real link (http:) that goes a website you control, such as a static website on amazon s3, use the javascript on that site to detect an android user agent and then redirect to a link with the anchor tag.




回答3:


<activity
android:name=".SplashEmailActivity"
android:screenOrientation="portrait"
android:exported="true"
android:launchMode="singleInstance" android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:windowSoftInputMode="stateHidden|adjustResize" >

<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="http"  android:host="your.domain.name"/>

</intent-filter>

</activity>



回答4:


To trigger app link on a device, for instance, of your case myappname://processtobedone/?id=1, the simplest way is to create a basic html page file (with name deeplink_test.html) and send to your email, after that open this email and click to the html file, open with Chrome browser and click on the anchor link.

<html>
    <head>
        <title>DeepLink Test</title>
    <head>
    <body>
        <a href="myappname://processtobedone/?id=1">run deeplink</a>
    <body/>
</html>



来源:https://stackoverflow.com/questions/14960248/launching-android-application-from-link-or-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!