Question

I wanted to register an intent-filter on my app so I can share a contact from other application to mine.

I can already achieve this by adding this to my manifest:

<intent-filter>
  <action android:name="android.intent.action.SEND" /> 
  <category android:name="android.intent.category.DEFAULT" /> 
  <data android:mimeType="text/*" />
</intent-filter>

The problem is that my application appears in all "Share" or "Send to" popups from other applications sharing text data. How can I limit this so my app only appears on the contact share popup?

I already tried to use android:host="com.android.contacts" inside <data> but didn't help.

Thanks!

Was it helpful?

Solution

When you set a android:host you also need to set an android:scheme otherwise it is ignored. Try setting it to be android:scheme="content". All this will do though is prevent you from accepting intents without a data URI that contain the authority "com.android.contacts".

That being said, the mime-type you have specified will accept any text based content. Is that what you intended? Maybe you should be using the contact item mime-type specified by Google.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top