问题
Just spent a couple of hours last night developing a pretty sweet video player for Honeycomb, and now I'd of course love for people to be able to use it.
How can I make my application listen for / receive "video play broadcasts"?
I'm guessing it's got something to do with the manifest.xml file, but I was unable to find anything about it on the Android Developer site.
I've tried using the following without much success:
<receiver android:name=".VideoPlayer">
<intent-filter>
<action android:name="android.intent.action.VIEW">
<data android:mimeType="video/*" />
</action>
</intent-filter>
</receiver>
回答1:
I eventually solved this one myself with the following code in my manifest.xml file:
<!-- Video player -->
<activity android:name=".VideoPlayer" android:label="@string/app_name"
android:theme="@style/BlackHolo" android:screenOrientation="sensorLandscape">
<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:scheme="rtsp" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
<data android:mimeType="application/sdp" />
</intent-filter>
<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:scheme="http" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
回答2:
Video players are usually implemented as activities. Hence, you would use an <activity> element for that action and MIME type, not a <receiver> element. You might also want to specify both the DEFAULT and BROWSABLE categories -- the latter would be needed for links clicked on in a Web browser.
来源:https://stackoverflow.com/questions/7370875/how-can-i-enable-users-to-play-video-using-my-app