Launching Android Application from link or email
Asked Answered
J

4

16

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.

Jake answered 19/2, 2013 at 14:46 Comment(1)
Possible duplicate of Make a link in the Android browser start up my app?Laveta
P
21

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.

Paresis answered 19/2, 2013 at 15:4 Comment(3)
Thanks and sorry for delayed reply @CommonsWare. I would try this.Jake
Hi Thanks for you answer and it works fine on most device but not in all as it is not working with HTC EVO 4G. Whenever i click on the link it directly opens up the browser and i am sure of why it is so. Also checked whether the any defaults being set and it is not set either.Jake
@Dinash: This approach may not work on various US-shipped HTC devices due to a workaround stemming from an import ban obtained by Apple. See commonsware.com/blog/2012/07/23/… and commonsware.com/blog/2012/07/24/…Paresis
S
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.

Sortie answered 19/2, 2013 at 14:48 Comment(3)
You don't even need the JavaScript. If the <intent-filter> has the Web page URL instead of the custom scheme, the user can choose to open the app directly.Paresis
@Paresis ah, thats how instagram must work. I always wondered how that was a choiceSortie
@Paresis Can you please tell how to define url instead of custom scheme.Rhinitis
H
0
<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>
Halfdan answered 18/5, 2016 at 11:33 Comment(0)
P
0

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>

Premier answered 6/2, 2019 at 13:13 Comment(1)
Email apps will strip this out, gmail for example strips thisIndiscreet

© 2022 - 2024 — McMap. All rights reserved.