Similar to sharing images/audio and plain text, I want to see my app when user shares event from default calendar app.
I am sure there is something to do with mime type.
As I see my app in list that shares images, similar to that I would like to see my app when an event is shared.
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/event" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
update,I am able to show my app in event sharing intent now using code below
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="*/*"/>
</intent-filter>
So, Working on similar lines what I was thinking changing to */*did the trick but its still not done as I need only for sharing events not images/videos/audios/text etc.
just need some mimetype that can support all types of events
Perfect!!
I was able to fix this, posting my answer here, so that anyone can use my solution in future
I was able to do this using text/x-vcalenda
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/x-vcalendar" />
</intent-filter>
Related
I am trying to provide two share option for image sharing, so i have two activity which can accept image type.It works well everywhere other than Google photos.
If i comment out one of them from manifest then it works fine , but if i keep both then only one will show up when i click on share button and clicking on it will take me to the other activity, not the one it is associated with.
This problem only occurs in Google photos app and nowhere else.
<activity
android:name="mobi.abc.xyz.NewPostActivity">
<intent-filter android:label="Socials">
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PICK" />
<data android:mimeType="text/plain" />
<data android:mimeType="application/*" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
<activity
android:name="mobi.abc.xyz.EditActivity">
<intent-filter android:label="Share Image to Edit">
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PICK" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
Hi I came here to write the same thing which #kolboc mentioned i.e google photos make filtrations because twitter and Instagram are famous apps and may be google giving them a priority and hence displaying both instances of sharing for those apps but I was wrong...
I found a solution to fix this ...
So the reason it is occurring is you are mentioning labels in the hardcoded string. So replace those with some String file names like this ...
<activity
android:name="mobi.abc.xyz.NewPostActivity">
<intent-filter android:label="#string/socials">
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PICK" />
<data android:mimeType="text/plain" />
<data android:mimeType="application/*" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
<activity
android:name="mobi.abc.xyz.EditActivity">
<intent-filter android:label="#string/share_image_to_edit">
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PICK" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
I don't know what kind of code they are using to label those but this was the problem that was causing this ... so just replace those it will work ...
Demo Image
I have marked the app instance by red but as you notice I have no control over the position of occurrences of my app instances. Google photos arrange them like this. Again I am not sure why? ... but as soon as I clicked on one of sharing intent of my app in the next attempt it shown my app instances like this ...
I think again google is being smart here ... I think they are making list based on last used priority...
Happy Coding.. :)
Let's say in my app, users can make posts & send messages to other users, & I want to register my app as a component among those appears in the Share-via picker when sharing either text or an image, I'm defining my 2 activities in my AndroidManifest.xml as follows (like this official example):
<activity
android:name=".SharePostActivity"
android:label="MyApp (Post)">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<activity
android:name=".ShareMessageActivity"
android:label="MyApp (Message)">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
When sharing text, this works perfectly fine, where I see 2 icons of my app among available apps for sharing text, named MyApp (Post) & MyApp (Message),
Problem happens when sharing an image, because only one icon appears with the second defined label in the manifest (which is MyApp (Message)), and actually it opens the first defined activity in the manifest (which is SharePostActivity),
So, how to show the 2 options when sharing an image (just like what happens when sharing text)?
(I've tried on an emulator running Nougat & a real device running Oreo)
----- Update -----
I've found that this weird behavior happens only when sharing images from Google's Photos app, but everything works fine when sharing an image from other apps!
Some investigation leads to a solution: each of your intent-filter must contain an android:label which points to a resource, not a hardcoded string.
...
<intent-filter android:label="#string/first_value">
...
Different Activities must have different labels, so in your case the Manifest should look like
<activity
android:name=".SharePostActivity"
android:label="#string/my_app_post">
<intent-filter
android:label="#string/my_app_post">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter
android:label="#string/my_app_post">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<activity
android:name=".ShareMessageActivity"
android:label="#string/my_app_message">
<intent-filter
android:label="#string/my_app_message">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter
android:label="#string/my_app_message">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
I'm building a app with sounds to be shared via WhatsApp, it's almost done, however is missing a single thing, that I already tried everything, but nothing seems to work.
I wanna that when the user click on share button of own whatsApp (the one that is a clip) my app be listed on list of possible apps to do that action, this way:
I already tried
use a intent filter on a activity like
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="audio/*" />
</intent-filter>
and too
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="audio/*" />
</intent-filter>
however my app wasn't shown, I already saw that is possible with other apps, I'm just doing something wrong.
How I can do to make my app be listed? Anyone knows?
Really Thx.
Note - the image is just a example, not a real one 'cause I can't print the screen of a real device, then I found this one on internet :(
EDIT 1
I tried this way too, but did not work
<activity
android:name=".activities.HomeActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.OPENABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
</intent-filter>
</activity>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="audio/*" />
</intent-filter>
//and too
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="audio/*" />
</intent-filter>
Replace With below code
//this is to get text from other app
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
</intent-filter>
For more idea here is an official document form android : https://developer.android.com/training/sharing/receive.html
What are the possible intent-filter I need to cover to make sure that any external app requesting an image will see my app in the list?
To clarify, I'd like my app to appear when doing the following:
So far I've covered:
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
However, if using the Tumblr app and pressing "Add photo", my app does not appear in the chooser dialog. Which filter am I missing out on?
I had covered the correct intent-filters, however the Tumblr app requires the category OPENABLE, so instead of the filters I had I'm now using:
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="image/*" />
</intent-filter>
Only adding the line:
<category android:name="android.intent.category.OPENABLE" />
Some applications may specify the application to open, and some applications have already set the default applications to Open.
The share feature uses the following intent filter
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
Remember that this does not mean an app is requesting a photo but that it wants to send one somewhere.
Use this <intent-filter>:
<intent-filter
android:icon="#drawable/icon"
android:label="Share to my app">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
is there any way to share text from my android app by using ACTION_SEND and google+ app.
Has anyone try that, which mimeType should i write?
Thanks for your answers
I am pretty sure that Google+ app has intent filters for text/plain and image/*. Here's what they have in the manifest:
<activity android:theme="#style/CircleBrowserTheme" android:name=".phone.PostActivity" android:launchMode="singleTop" android:logo="#drawable/ic_menu_stream">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
So you should be able to putExtra a String onto your intent and setType("text/plain") and that will most likely work just fine. Looks like you won't be able to send both a text and a picture at the same time, though, as SEND_MULTIPLE on G+ only takes images.