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?

4

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

4 Comments

How do I get the complete URL out of the same (I am trying to get an argument from the URI)
You may use intent.getDataString() to get complete url. Reference stackoverflow.com/a/1609662/2641380
This only works with http/https protocol. It doesn't work with custom protocol , such as navigon:// as in @Tim Castelijns's question
` <!-- note that the leading "/" is required for pathPrefix-->` 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.
6

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

3 Comments

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 <a href="navigon://">Open Navigon</a> would open Navigon app if installed on an iOS device.
Ohh sure there are ways, I'll let you know as soon as I am home. right now, I've gotta run.
Here's how you can invoke Google Apps on Android device: developer.android.com/guide/appendix/g-app-intents.html though, the following links are also a nice read.
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); } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.