用于服务启动的意图过滤器 [英] Intent-filter for service start

查看:61
本文介绍了用于服务启动的意图过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启动一个服务,该服务基本上是windowmanager上的videoview.我想从其他应用程序启动此videoview服务.这是我的代码意图过滤器,不知道我哪里出了错.

I want to start a service, the service is basically a videoview on windowmanager. I want to start this videoview service even from other applications. this is my code intent-filter, Don't know where I went wrong.

  <service android:name=".VideoWindow">
     <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:mimeType="video/*"  />
            <data android:mimeType="application/x-quicktimeplayer*" />
            <data android:mimeType="application/x-mpeg" />
            <data android:mimeType="application/vnd.dvd*" />
            <data android:mimeType="application/vnd.3gp*" />
            <data android:mimeType="application/3gpp*" />
            <data android:mimeType="application/vnd.rn-realmedia*" />
            <data android:mimeType="application/mp4*" />
            <data android:mimeType="application/mpeg*" />
            <data android:mimeType="application/sdp" />
            <data android:mimeType="application/vnd.wap.mms-message"/>
     </intent-filter>
</service>

推荐答案

我甚至想从其他应用程序启动此视频观看服务

I want to start this videoview service even from other applications

除非您是编写其他应用程序的人,或者雇用其他人编写其他应用程序,否则其他应用程序都不会启动您的服务.

Unless you are the one writing those other applications, or you hire people to write those other applications, no other applications will start your service.

根据您的< intent-filter> ,我的猜测是,您认为如果另一个应用程序在 ACTION_VIEW startActivity()> Intent ,这将启动您的服务.这是不正确的. startActivity()启动一个活动.无论该服务具有什么< intent-filter> ,它都不会启动服务.

My guess, from your <intent-filter>, is that you think that if another app calls startActivity() on an ACTION_VIEW Intent, that this will start your service. This is incorrect. startActivity() starts an activity. It will not start a service, no matter what <intent-filter> that service has.

这篇关于用于服务启动的意图过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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