The chrome solution on Android does not trigger intent when clicking a link

TIMEOUT

It may eventually be repaired, but at the same time, does anyone know the solution?

If I control the link myself, I can use my own HTTP scheme, such as myapp: / /..., or I can use JavaScript to make a button click. Both send intentions... But I don't control the link

Specifically, I want to deal with things like http://github.com/snarfed Such links. My activity is defined in androidmanifest.xml as follows. It correctly receives the intention broadcast of such link clicks from other applications, not from chrome

<activity android:name="MyApp" android:exported="true">
  <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" />
    <data android:scheme="https" />
    <data android:host="github.com" />
  </intent-filter>
</activity>

resolvent:

You need to include scheme, host and pathprefix in each data point

Examples of appropriate Checklists:

<activity
    android:name=".PhotostreamActivity"
    android:label="@string/application_name">

    <!-- ... -->            

    <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="flickr.com"
              android:pathPrefix="/photos/" />
        <data android:scheme="http"
              android:host="www.flickr.com"
              android:pathPrefix="/photos/" />
    </intent-filter>
</activity>

This example is taken from the application put together by Romain guy, and repeat the question here:

Intercepting links from the browser to open my Android app

A few points to note. It seems that you need to kill chrome in the background before the intention mapping takes effect. If you directly enter the URL, the application will not be allowed to use it. The action of the application is only when it is a link provided by chrome

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>