android – 为服务指定SEND(共享)意图过滤器

我试图在我的一个服务中过滤和处理 android.intent.action.SEND操作的意图.我在 AndroidManifest.xml中写了以下内容
<service 
    android:name=".app.ScreamerService"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="*/*"/>
    </intent-filter>                                                                    
</service>

现在,问题是我没有在“共享通过”选项列表中看到我的应用程序,例如,尝试从浏览器共享网页或联系人列表中的联系人.但是,如果我将intent过滤器移动到主< activity> tag(而不是< service>),我的应用程序名称和图标确实出现在“share via”选项列表中.

在这做错了什么?不能将SEND操作定向到服务吗?

解决方法

I am trying to filter and handle intents with android.intent.action.SEND actions in one of my services.

ACTION_SEND是一项活动动作,因此无法由服务或广播接收者接收.

Now,the problem is that I don’t see my application in the list of “share via” options when,for instance,

那是因为它不是一项活动.

Can’t a SEND action be directed to a Service?

出现在选择器中的事物(例如,对于ACTION_SEND)必须是活动.不过,欢迎您的活动与服务进行沟通.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...