31

I can add a link to, for example, 'navigon://' on a website that, in iOS devices, will open up the Navigon app if it is installed.

Is there a similar simple method to open an app from a website (assuming it's installed) in Android?

Tim
  • 41,901
  • 18
  • 127
  • 145
MaFt
  • 478
  • 1
  • 4
  • 9
  • Hi @MaFt I have the same problem like you Did you find solution? – Konrad Krakowiak Feb 03 '15 at 16:11
  • I have done this in my android app, using intent filter, now the problem is the url link using in email is redirected to another one that i need. And the initial link does not get detected. How can i resolve this? – arslan haktic Feb 04 '15 at 12:51
  • 1
    Answered here: http://stackoverflow.com/questions/525063/android-respond-to-url-in-intent and here: http://stackoverflow.com/questions/2448213/how-to-implement-my-very-own-uri-schema-on-android – pawelzieba Feb 21 '11 at 13:36
  • Hope this will help you or someone else http://stackoverflow.com/questions/40781149/app-link-not-working-for-facebook-on-android/40781465#40781465 – Naeem Ibrahim Nov 24 '16 at 08:53

3 Answers3

21

Android deep linking: Add an intent filter to your manifest

<activity
android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_title_viewgizmos">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
    <data android:scheme="http"
          android:host="www.example.com"
          android:pathPrefix="/gizmos" />
    <!-- note that the leading "/" is required for pathPrefix-->
    <!-- Accepts URIs that begin with "example://gizmos”
    <data android:scheme="example"
          android:host="gizmos" />
    -->
</intent-filter>

https://developer.android.com/training/app-indexing/deep-linking.html

DeaMon1
  • 572
  • 5
  • 10
  • How do I get the complete URL out of the same (I am trying to get an argument from the URI) – jeet.chanchawat Dec 20 '15 at 18:37
  • 1
    You may use intent.getDataString() to get complete url. Reference http://stackoverflow.com/a/1609662/2641380 – SHS Jun 18 '16 at 09:03
  • This only works with http/https protocol. It doesn't work with custom protocol , such as navigon:// as in @Tim Castelijns's question – Albert Mar 06 '17 at 14:35
  • ` ` is very very important, I was trying url apit-testing in postman and wondering why same url it's not opening in android, for stripe-terminal-android-app. – GD- Ganesh Deshmukh Nov 07 '19 at 12:46
6

Check out intent filters in Android. Check out the Category specially.

Aman Alam
  • 11,231
  • 7
  • 46
  • 81
  • 2
    Thanks but that refers to coding an app using the Android SDK. I need a way to open an app from a web page 'a' link eg Open Navigon would open Navigon app if installed on an iOS device. – MaFt Feb 21 '11 at 12:56
  • Ohh sure there are ways, I'll let you know as soon as I am home. right now, I've gotta run. – Aman Alam Feb 21 '11 at 13:18
  • Here's how you can invoke Google Apps on Android device: http://developer.android.com/guide/appendix/g-app-intents.html though, the following links are also a nice read. – Aman Alam Feb 22 '11 at 07:30
1

See Everything you need to know about implementing iOS and Android Mobile Deep Linking. This is a good article for Android and iOS.

You may already have known that there are Deep Links, and starting from Android 6.0 Android App Links appeared. The latter are intended to open an URL only in your application, not any other competing. For instance, reddit.com can be opened in 7 applications, if not use this verification.

enter image description here

You can associate every needed Activity with links from which it should be opened. For instance, if you wish to open in the application links like https://awesomejobs.com/jobs/{id}, you need to add these lines to AndroidManifest.xml:

<activity android:name="com.awesomejobsapp.ui.activity.JobActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.DEFAULT" />

        <data android:scheme="https"
              android:host="awesomejobs.com"
              android:pathPrefix="/jobs" />
    </intent-filter>
</activity>

Then in JobActivity write (a code is received from an article in Russian):

@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.ac_job);

   final Intent intent = getIntent();
   final String action = intent.getAction();
   final String data = intent.getDataString();

   if (Intent.ACTION_VIEW.equals(action) && data != null) {
      final String jobId = data.substring(data.lastIndexOf("/") + 1);
      loadJobDetails(jobId);
   }
}
CoolMind
  • 26,736
  • 15
  • 188
  • 224