ACTION_SEND and Google+ App in Android - android

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.

Related

How can I share an audio from whatsapp to my android app?

I'm trying looking for resources to know how to share audio from WhatsApp to my app, but I can't find any. I only have found how to share from app to WhatsApp but not from WhatsApp do an android app. If you know some resource that may help me, I will be very happy with it.
Cheers!
You should use a intent filter for your problem such as a one below,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file"/>
<data android:mimeType="audio/*"/>
</intent-filter>
I think the action needs to be changed.
An intent filter must be defined in the Manifest.xml file
After declaring the intent-filter your Manifest.xml will look like this,
<activity android:name=".MainActivity">
<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.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file"/>
<data android:mimeType="audio/*"/>
</intent-filter>
</activity>

Registering 2 activities to receive images, it doesn't work when sharing from Google Photos app

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>

How I make my app to be shown on available apps that have audio to share

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

Android: Share event from default Calendar to my app

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>

What intent-filters must my app cover to appear in chooser when requestion an image from an external app?

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>

Categories

Resources