12

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.

CopsOnRoad
  • 109,635
  • 30
  • 367
  • 257
Dinash
  • 2,908
  • 4
  • 30
  • 45
  • Possible duplicate of [Make a link in the Android browser start up my app?](http://stackoverflow.com/questions/3469908/make-a-link-in-the-android-browser-start-up-my-app) – Tot Zam Feb 27 '17 at 01:00

4 Answers4

20

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.

Tot Zam
  • 7,081
  • 9
  • 45
  • 66
CommonsWare
  • 910,778
  • 176
  • 2,215
  • 2,253
  • Thanks and sorry for delayed reply @CommonsWare. I would try this. – Dinash Feb 20 '13 at 07:17
  • 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. – Dinash Feb 26 '13 at 06:12
  • @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 http://commonsware.com/blog/2012/07/23/linkify-problem-patent-behavior.html and http://commonsware.com/blog/2012/07/24/linkify-problem-detection-mitigation.html – CommonsWare Feb 26 '13 at 12:52
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.

CQM
  • 36,672
  • 69
  • 214
  • 357
  • 1
    You don't even need the JavaScript. If the `` has the Web page URL instead of the custom scheme, the user can choose to open the app directly. – CommonsWare Feb 19 '13 at 14:49
  • @CommonsWare ah, thats how instagram must work. I always wondered how that was a choice – CQM Feb 19 '13 at 15:01
  • @CommonsWare Can you please tell how to define url instead of custom scheme. – CodingRat Jul 22 '14 at 10:59
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>
Teraiya Mayur
  • 964
  • 8
  • 18
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>

ultraon
  • 1,630
  • 2
  • 20
  • 29