Android YouTube app Play Video Intent

前端 未结 18 1378
太阳男子
太阳男子 2020-11-22 11:17

I have created a app where you can download YouTube videos for android. Now, I want it so that if you play a video in the YouTube native app you can download it too. To do t

18条回答
  •  庸人自扰
    2020-11-22 11:54

    Intent videoClient = new Intent(Intent.ACTION_VIEW);
    videoClient.setData(Uri.parse("http://m.youtube.com/watch?v="+videoId));
    startActivityForResult(videoClient, 1234);
    

    Where videoId is the video id of the youtube video that has to be played. This code works fine on Motorola Milestone.

    But basically what we can do is to check for what activity is loaded when you start the Youtube app and accordingly substitute for the packageName and the className.

提交回复
热议问题