Specify a SEND (sharing) intent filter for a service

I am trying to filter and process intentions with android.intent.action.SEND actions in one of my Service s. I wrote the following in 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> 

Now the problem is that I do not see my application in the list of options "share via" when, for example, I try to share a web page from a browser or with a contact from the contact list. If, however, I move the intent filters to the main <activity> (instead of <service> ), the name of my application and the do icon are displayed in the list of share via options.

What am I doing wrong here? Can't submit the SEND action to the service?

+8
android android-intent android-manifest android-sharing intentfilter
source share
2 answers

I am trying to filter and process intentions using android.intent.action.SEND actions in one of my services.

ACTION_SEND is an action action and therefore cannot be picked up by services or broadcast receivers.

Now the problem is that I do not see my application in the list of options "share via", if, for example,

This is because it is not an action.

Can't submit the SEND action to the service?

Things that appear in the selection (e.g. for ACTION_SEND ) must be valid. However, you can communicate with the service.

+9
source share

This should work, but:

Try with the broadcast receiver to first get the intention and start the service.

if this does not work:

Use dummy activity without layout. (Make the theme translucent and end the call immediately after you cope with the intention).

Also your mime type means that you process each type of file. that's what you need? I think you should clarify it in your choice. you will receive negative feedback if someone tries to use it with a type that you do not support. my suggestion is to test types and add them one by one, as you are sure you can handle them.

+1
source share

All Articles