How to catch Android share intents limited to specific URLs using intent-filter?

∥☆過路亽.° 提交于 2019-12-05 18:08:45

问题


I can hook my app into the "Share page" feature using the following intent-filter:

<intent-filter>
  <action android:name="android.intent.action.SEND" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="text/plain" />

But I would like to go a little further and limit the filter to intents with specific URLs in them, for example URL of a YouTube video. I tried something like this but it doesn't work:

<intent-filter>
  <action android:name="android.intent.action.SEND" />
  <category android:name="android.intent.category.DEFAULT" />
  <data
    android:mimeType="text/plain"
    android:scheme="http"
    android:host="m.youtube.com"
  />

Any suggestions?


回答1:


But I would like to go a little further and limit the filter to intents with specific URLs in them, for example URL of a YouTube video.

What you are asking for makes no sense to me as written.

Perhaps you really mean:

But I would like to go a little further and limit the filter to ACTION_SEND requests where the body extra contains a specific URL

In which case, that is impossible, sorry.

Or, perhaps you really mean:

But I would like to go a little further and limit the filter to ACTION_SEND requests issued from random pieces of software that happen to be thinking of a specific URL at the time user happened to press "share", such as sharing the current YouTube video being played in the YouTube app

In which case, that is impossible, sorry.

If neither of those guesses really hit what you are asking for, please consider editing your question.



来源:https://stackoverflow.com/questions/4986612/how-to-catch-android-share-intents-limited-to-specific-urls-using-intent-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!