安卓应用程序注册为接收器 [英] Android: register App as receiver

查看:111
本文介绍了安卓应用程序注册为接收器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序能够从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 在不同的音频文件类型,文件,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屋!

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