3

Im trying to receive an intent from the Youtube App. I.e. when i press share it should list my app on the apps ready to accept this intent. But none of these works

<intent-filter>
  <action android:name="android.intent.action.SEND" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="image/*" />
  <data android:mimeType="video/*" />
  <data
    android:host="*"
    android:scheme="youtube" />
  <data
    android:host="*"
    android:scheme="vnd.youtube" />
</intent-filter>

or with action VIEW

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="image/*" />
  <data android:mimeType="video/*" />
  <data
    android:host="*"
    android:scheme="youtube" />
  <data
    android:host="*"
    android:scheme="vnd.youtube" />
</intent-filter>

Any idea about how to get the intent as well once sent? Thanks

peshkatari
  • 151
  • 3
  • 15

3 Answers3

0

The YouTube app sends text/plain data, so register your activity as a receiver of that mimetype:

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>
acj
  • 4,821
  • 4
  • 34
  • 49
0
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data
                android:host="www.youtube.com"
                android:mimeType="text/*" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data
                android:host="m.youtube.com"
                android:mimeType="text/plain" />
        </intent-filter>
Alexey
  • 4,384
  • 1
  • 26
  • 34
0

You seem to be quite confused. The intents you are using seem to be the intents that an app like the YouTube app itself would use to open videos. What you want is to share a YouTube video, i.e. a link, so as the other answers mention, you should declare a text/plain intent-filter.

However, this intent-filter will capture all text/plain content and not only the ones that come from YouTube. See: Intent-filter: How to accept only "text/plain" intents containing the word "spaghetti"

Community
  • 1
  • 1
cprcrack
  • 17,118
  • 7
  • 88
  • 91