android youtube: share a youtube video TO my app?

我只是一个虾纸丫 提交于 2019-11-30 00:13:29

This worked for me. Add this intent filter to your manifest file to make your application appear in the share list of the youtube application.

<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>

Then to retrieve it in your activity, use this :

Bundle extras = getIntent().getExtras();
 String value1 = extras.getString(Intent.EXTRA_TEXT);

Here you are!

It looks like Youtube have changed share intent so for me only solution that works is the one I copied from android Telegram manifest. Solution is tested and working on Marshamallow 6.0.1 and Lolipop 5.1.1.

        <intent-filter android:label="@string/app_name">
            <action android:name="android.intent.action.SEND"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="*/*"/>
        </intent-filter>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!