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 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...