Android:拦截YouTube意图? [英] Android: intercept Youtube intents?

查看:84
本文介绍了Android:拦截YouTube意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当视频开始播放时,我想在youtube应用中使用BroadcastReceiver截取意图-我设法从日志中读取了这一点:

I would like to intercept an intent with a BroadcastReceiver, in the youtube app, when a video starts to play - I managed to read this from the logs:

Starting: Intent { cmp=com.google.android.youtube/.WatchActivity (has extras) } from pid 18710

我试图将其添加到清单中

I tried to add this to the manifest:

<intent-filter>
        <component android:name="com.google.android.youtube/.WatchActivity"/>

        </intent-filter>

但这没用.

你怎么看?

推荐答案

如果要让您的应用响应特定格式的HTTP URL(例如youtube视频URL),请设置一个意图过滤器,以< data>元素,它定义了您要匹配的网址格式.

If you want to let your app respond to specifically formed HTTP URLs such as a youtube video URL, set up an intent filter that responds to ACTION_VIEW intents with a <data> element that defines the URL pattern you want to match.

Android使用ACTION_SEND意图共享链接或照片之类的内容.您还可以让您的应用响应共享链接.进行设置几乎与为ACTION_VIEW意图设置意图过滤器相同.

Android uses ACTION_SEND intents to share things like links or photos. You can also have your app respond to shared links. Setting this up will be almost the same as setting up an intent filter for ACTION_VIEW intents.

有关意图过滤器,请参见Android文档的数据测试"部分

See the "data test" section of the Android documentation on intent filters here for more detail.

一种或另一种方法,没有一种方法可以静默地监视"另一个第三方应用程序,除非该应用程序将信息发布给其他应用程序以供阅读.以上两种方法都将涉及到用户专门告诉系统使用您的应用来处理所涉及的URL的问题.第一种方式,用户将首先选择要使用哪个应用来查看内容.第二种方式,用户必须在原始应用程序中按一个共享"按钮,然后选择共享指向您应用程序的链接.

One way or another, there is not a way to "spy" on another 3rd party app silently unless that app publishes the information for other apps to read. Both of the approaches above will involve the user specifically telling the system to use your app to handle the URL in question. The first way, the user will get to pick which app to use to view the content in the first place. The second way, the user will have to press a share button in the original app and choose to share the link to your app.

所有这些都说明了,因为您在上面提到了您要尝试做的事情,所以请尊重他人的版权.

All of that said, since you mentioned what you're trying to do above, please respect the copyrights of others.

这篇关于Android:拦截YouTube意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆