Intent-filter for service start

China☆狼群 提交于 2021-01-28 18:52:52

问题


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>

回答1:


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.

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.



来源:https://stackoverflow.com/questions/40058679/intent-filter-for-service-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!