安卓应用程序注册为接收器 [英] Android: register App as receiver
问题描述
我想我的应用程序能够从Android资源管理器接收图片/语音文件等。
应用什么样的应用程序,在Hangouts,Gmail已经注册。如何添加我的应用程序作为接收器?
I'd like my app to be able to receive pictures/audiofiles etc. from the android-explorer. Apps like what's app, hangouts, gmail are already registered. How can I add my app as receiver?
我不知道我应该寻找。
感谢的任何提示:)
I'm not sure what I should be looking for. Thank's for any hints:)
推荐答案
您<活性GT;
将需要一个合适的<意向滤光器&gt ;
,最好对过滤MIME类型
Your <activity>
will need an appropriate <intent-filter>
, ideally filtering on MIME type.
例如,这套&LT;意向滤光器&gt;从AOSP音乐应用
元素允许它以 ACTION_VIEW $ C响应$ C>在不同的音频文件类型,文件,HTTP流和
的ContentProvider
流:
For example, this set of <intent-filter>
elements from the AOSP Music app allow it to respond to ACTION_VIEW
on various audio file types, for files, HTTP streams, and ContentProvider
streams:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file"/>
<data android:mimeType="audio/*"/>
<data android:mimeType="application/ogg"/>
<data android:mimeType="application/x-ogg"/>
<data android:mimeType="application/itunes"/>
</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="audio/*"/>
<data android:mimeType="application/ogg"/>
<data android:mimeType="application/x-ogg"/>
<data android:mimeType="application/itunes"/>
</intent-filter>
<intent-filter
android:priority="-1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" />
<data android:mimeType="audio/*"/>
<data android:mimeType="application/ogg"/>
<data android:mimeType="application/x-ogg"/>
<data android:mimeType="application/itunes"/>
</intent-filter>
这篇关于安卓应用程序注册为接收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!