title: Which intent-filter scheme use for Youtube in Android
body: <p>I want to register an intent-filter exclusively for the share in the Youtube app.</p>
  
  <p>So far I'm able to receive the intent from Youtube successfully. The problem is my intent filer is not specific enough. My app is displayed as available for other share features in other apps (not only for Youtube).</p>
  
  <p>This is what I'm using right now:</p>
  
  <pre><code>&lt;intent-filter&gt;
      &lt;action android:name="android.intent.action.SEND" /&gt;
      &lt;category android:name="android.intent.category.DEFAULT" /&gt;
      &lt;data android:mimeType="text/plain" /&gt;
  &lt;/intent-filter&gt;
  </code></pre>
  
  <p>I have reviewed several questions (most are much like <a href="https://stackoverflow.com/a/38589296/4017501">this one</a>) the problem is there is an inaccuracy in those types of answers:</p>
  
  <pre><code>&lt;data android:host="www.youtube.com" ... /&gt;
  </code></pre>
  
  <p>According to the <a href="https://developer.android.com/guide/topics/manifest/data-element.html" rel="nofollow noreferrer">data documentation</a> the <code>scheme</code> most be provided in order for the <code>host</code> to be valid. So in those answers simply adding the host, doesn't make the <code>intent-filter</code> specific for Youtube, because there is no <code>scheme</code>, therefore, the <code>host</code> is ignored.</p>
  
  <p>So I have been trying to figure this out by using the available methods of the <code>intent</code> when the Activity is started:</p>
  
  <pre><code>    Intent intent = getIntent();
  
      Bundle bundle = intent.getExtras();
      for (String key : bundle.keySet()) {
          Log.d("KEY", key);
      }
  
      //The above loop will log
      //... D/KEY: android.intent.extra.SUBJECT
      //... D/KEY: android.intent.extra.TEXT
  
      //This is are the same keys than above, but using the available constants
      String subject = getIntent().getStringExtra(Intent.EXTRA_SUBJECT);
      String text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
  
      //The subject is the video title
      Log.d("SUBJECT", subject);
  
      //The text is the video url, example: https://youtu.be/p6qX_lg4wTc
      Log.d("TEXT", text);
  
      //Action is consistent with the intent-filter android.intent.action.SEND
      Log.d("ACTION", intent.getAction());
  
      //This is consistent with the intent-filter data mime type text/plain
      Log.d("TYPE", intent.getType());
  
      /*
        This is the problem.
        The scheme is null (that is why I'm using String value of).
      */
      Log.d("scheme", String.valueOf(intent.getScheme()));
  </code></pre>
  
  <p>So, when the available information in the intent is checked, everything seems to be in order, <strong>but not the scheme</strong>. So, based on what is gotten, I have done some <em>blind</em> attempts to figure it out:</p>
  
  <pre><code>&lt;data android:scheme="http" android:mimeType="text/plain"/&gt;
  
  //I'm adding youtu.be here because is the url format in the text extra
  &lt;data android:scheme="http" android:host="youtu.be" android:mimeType="text/plain"/&gt;
  </code></pre>
  
  <p>Adding <code>http</code> or <code>https</code> won't work, it makes the app is no longer available in the chooser. This means it will neither work the other attempt adding the <code>host</code>.</p>
  
  <p><strong>Doe's anybody knows how to create an <code>intent-filter</code> exclusively for Youtube share?</strong></p>
  
  <p>PS: I know I could validate the url to see if it match a Youtube url, but having my app in every chooser matching <code>SEND</code> doesn't seem user friendly</p>