android youtube: share a youtube video TO my app?

前端 未结 3 1655
执笔经年
执笔经年 2020-12-24 08:56

The built in YouTube App for tablets has a sharing-option. For example: I watch a video in the YouTube app and click the button to share. Bluetooth, Googlem

相关标签:
3条回答
  • 2020-12-24 09:18

    I played around a bit and ended with this solution:

    <intent-filter android:label="My YT Handler">
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:host="youtu.be" android:mimeType="text/*" />
    </intent-filter>
    
    0 讨论(0)
  • 2020-12-24 09:19

    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!

    0 讨论(0)
  • 2020-12-24 09:30

    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>
    
    0 讨论(0)
提交回复
热议问题