Android M - application does not work in Chrome

So, I am looking for application implementation in some new applications, and I read the notes of the developers quite carefully, installed the server, added the file with the correct json header and created a test application. The app interaction introduced in Android M seems to work if I send an email with attached links, but when I do this on the model page in chrome, it just reloads the page. I just hit the root page on my web server. ( https://www.EXAMPLE.com ). At first, I had some problems with the chrome certificate on my tablet, but I added the root certificate and now it looks green.

I am using Nexus 7 2013, recently wiped and running Android M and Chrome, updated.

I serve the HTML file on my server (it would seem that if I had a page back).

Any idea if this is how I use the webpage / backtrack, or if I did something wrong. It works great in Gmail, without a task selector, but not in chrome.

I tried to add some examples that html looks like and no one worked.

<a href="EXAMPLE://">Click HERE for schema</a> <a href="https://www.EXAMPLE.com/">Click HERE for url with slash</a> <a href="https://www.EXAMPLE.com">Click HERE for url, no slash</a> <a href="#" onclick="window.location('https://www.EXAMPLE.com/')">Trying with onclick javascript</a> 

My android manifest:

 <activity android:name=".deepActivity" android:label="@string/title_activity_deep" > <intent-filter android:autoVerify="true"> <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="www.EXAMPLE.com" /> <data android:scheme="https" android:host="www.MYDOMAIN.com" /> <!-- note that the leading "/" is required for pathPrefix--> <!-- Accepts URIs that begin with "example://gizmos"--> </intent-filter> 

https://developer.android.com/training/app-links/index.html

edit:

I tested auto-check with the following command:

 adb shell dumpsys package d | grep DOMAIN -ab5 

and I get the results:

 230: Package: com.DOMAIN.deeplinkingtest 275: Domains: www.DOMAIN.com 308- Status: undefined 

From the documentation

Shows the current link processing setting for this application. The application that has passed the test and whose manifest contains android: autoVerify = "true" always shows the status. The hexadecimal number after this status is associated with the Android system record for user application binding settings. This value does not indicate whether the test passed.

+5
source share
2 answers

Add an HTML tag to your website. <a href="http://domain.com" data-applink="domain.com">Link</a>

AndroidManifest.xml

`

 <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <data android:scheme="http" /> <!-- or you can use deep linking like --> <data android:scheme="http" android:host="domain.com"/> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> 

`

0
source

... but when I do this on the model page in chrome, it just reloads the page

I assume that you mean that you just go into Chrome and type https://example.com in the browser bar.

Unfortunately, the Linking application will not work if you enter the URL into the browser panel. This may seem disappointing, but there is a good reason why this should not work. According to Paul Kinlan, Google Dev Advocate explains that this will be a bad user interface:

If the user enters the URL into the address bar of the system, the intention of the user is to visit the page in question. We do not believe that the user intended to go to the application. Ergo, redirecting the user of the application does not work well.

link

This answer only applies to entering the URL into the Chrome URL bar . But the same (mostly) is true if the user clicks a link on a web page . Let us know why everything doesn’t work with each of your links to examples. I'll start in the middle:

<a href="https://www.EXAMPLE.com/">Click HERE for url with slash</a>

<a href="https://www.EXAMPLE.com">Click HERE for url, no slash</a>

For these links to launch your application, Chrome must send the intent to the system using action.VIEW , category.DEFAULT **, category.BROWSABLE and a scheme of either http or https . You can create an intent filter that catches this intent (your app attachment intent filter will work):

 <intent-filter android:autoVerify="true"> <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"/> <data android:scheme="https"/> <data android:host="www.example.com"/> </intent-filter> 

If you check the logs (or just check them as is), you can see that Chrome does not smooth out the intent. They prefer to handle this link internally (by going to a new page). This is a feature of Chrome, not Android. Unable to change this. However, you can specify a custom scheme in the URL that Chrome will abide by. This leads me to your first url:

<a href="EXAMPLE://">Click HERE for schema</a>

Chrome will respect the scheme in this URL and dismiss the intent: action.VIEW , category.DEFAULT **, category.BROWSABLE and the EXAMPLE scheme. Depending on how you have your intent filter settings, this will launch your application. Your first impulse might be to add an EXAMPLE schema to your application intent filter:

 <intent-filter android:autoVerify="true"> <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"/> <data android:scheme="https"/> <data android:scheme="EXAMPLE"/> <data android:host="www.example.com"/> </intent-filter> 

This will allow you to click the link in Chrome and open Chrome for Chrome. However, it will break the connection with applications . The pro solution is to leave the app join intent filter unchanged and add a second intent filter to catch your own scheme:

 <!-- EXAMPLE scheme intent filter --> <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="EXAMPLE"/> <data android:host="www.example.com"/> </intent-filter> <!-- App Linking intent filter --> <intent-filter android:autoVerify="true"> <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"/> <data android:scheme="https"/> <data android:host="www.example.com"/> </intent-filter> 

This is probably TMI, but going to the root helps to understand why everything works / does not work.

** Remember that the system will add category.DEFAULT to any implicit intent.

==============================================>

UPDATE: I have to add that using your own schema is bad practice. The absolutely best approach is documented here.

0
source

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


All Articles