问题
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