Open my application from URL scheme in Android

I know that there are several questions about this, but none of them help solve my problem.

I want to be able to click the link from email / text / browser and open my application.

I have AndroidManifest.xml code:

<!-- Splash Activity --> <activity android:name=".ui.SplashActivity" android:label="@string/app_name" android:theme="@style/SplashTheme" android:launchMode="singleTask"> <!-- Launcher intent filter --> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <!-- Branch URI scheme --> <intent-filter> <data android:scheme="myscheme" android:host="open" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter> </activity> 

It seems to be consistent with the documentation here , however, when I use Chrome (or Android Browser) to go to myscheme://open , my application does not open, and instead I get Google search results for myscheme: // open .

Can anyone see which part of the puzzle I am missing? How can I open my application through a URI?

Small update:

After reading this , I found that switching from Chrome to market://details?id=com.myapp makes the play store not open. Instead, it returns Google search results - just like trying to launch my application directly. This is confusing. Am I missing a global OS setting for deep binding?

+5
source share
2 answers

Chrome does not open applications from manually entered URI schemes. In fact, a manually linked link will never launch an external application in Chrome. This is by design - for some reason, the Chrome team believes that users should always be inside the browser after entering the address.

You can get around this to some extent by adding a deep link for the user drive action (for example, the standard <a> tag), but Chrome has its own standard called Chrome Intents, which you should use instead. Depending on the device used, this may also be the case for a standard browser.

In other applications, this applies to the application in question whether the custom URI scheme is defined as a click-through link. For better compatibility, you'll want to wrap it in a regular http:// link using redirection.

If you are interested in a detailed explanation of the complications surrounding deep linking, this post is a good place to start. If you just want it to work effortlessly, Branch.io (full disclosure: I am in the branch) solves this problem as a free service.

+2
source

There is no need to pay attention to myscheme://open in the application.

In particular:

  • For a web browser, there is no need to try to run a third-party application when entering myscheme://open in the address bar, since users are unlikely to do this in the real world.

  • It is not required that the email program attempt to create an ACTION_VIEW Intent for myscheme://open .

  • The SMS client does not require searching for all incoming messages for the myscheme://open , understands that this is somehow a link to the application and something to do with it.

You will have somewhat better luck overall, using the https URL (or, in the extreme case, http ) as a link to your application (URL http://www.example.com/gizmos from the documentation related to ). Then SMS clients can recognize that this is a URL and do something with it. And, in general, you should be taken either to your application or to your web page, which are at least somewhat useful to the user. However, your application will still not necessarily open when the user enters your URL into the address bar, as browsers may not expect that a link to the application will be entered in it.

You can increase the chances of a https link by working the way you want, publishing a digital asset link file and linking it to your manifest.

However, overall, it still depends on how customers prefer to pay attention to this material. Sometimes they will, because Android makes it relatively easy. Sometimes they do not. The web browser can see your URL, see that it is https , say β€œhey, like a web browser, I know how to deal with this!”, And load this web page, ignoring the installed application. You and I might consider this a bug in this browser; the developers of this browser may disagree.

I found that switching to Chrome on the market: // details? id = com.myapp does not open the play store

This refers to the fact that "developers can do what they want." If you clicked a link on a web page to this URL, it’s likely that Chrome will transfer you to the Play Store. However, Chrome is not required to treat the address bar the way it treats a link on a web page.

+1
source

Source: https://habr.com/ru/post/1265564/


All Articles