the following code is the sharing pdf with UNTITLED.pdf
how to name the pdf
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("application/pdf");
String shareMessage= "dummy";
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse(targetPdf));
startActivity(Intent.createChooser(sendIntent, "dummy"));
what I should put in putextra to change the shared pdf from UNTITLTED to dummy?
The activity that handles the ACTION_SEND Intent can do what it wants. There is no way to force it to do anything, in part because there are thousands of ACTION_SEND activities, each created by a different development team. So,
Some might pay attention to your EXTRA_TEXT, and some might not, as the ACTION_SEND specification only supports either EXTRA_TEXT or EXTRA_STREAM, and you are using both
Some might look at the last path segment of the Uri and assume that it is some sort of filename; others might not
So, populate the Intent as you are, perhaps tweak the values a bit, and otherwise just live with it.
Related
In my android app i want to share a Link to my website using intent but i dont want it to be visible to other user
example i want to share "smoe website link"
But to user it should look like "Click me to see it".
I tried this but wasnt successfull it just shows the simple text and was not clickable
<string name="app_link">Click me!</string>
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra("PostID", postID);
intent.putExtra("UserID", userID);
intent.putExtra(android.content.Intent.EXTRA_TEXT,activity.getString(R.string.app_link);
activity.startActivity(Intent.createChooser(intent, "Share"));
Any help will be really appreciated.
What you want is not realistically possible right now.
EXTRA_TEXT must always be interpreted as plain text by the receiving app. You could try using EXTRA_HTML_TEXT which was added with API 16. But many apps don't support HTML and will simply use EXTRA_TEXT instead (or not show any text at all if you omit EXTRA_TEXT).
Am doing photo sharing in my application.for that am using Adding an Easy Share Action.it show only icon in the action bar,not options.so please suggest me with some example.
http://developer.android.com/training/sharing/shareaction.html
Easy Share is auto-populating; you only need to tell the ShareActionProvider what content it is you will be sharing.
Most of this is shared in the API link you provided, but if you are aiming to populate the list for the images you aim to be sharing, you would need to include this.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
Now that the shareIntent has been set to image, it will populate the list with the related apps, such as instagram, facebook or PhotoShop.
The app will view the images as a MIME type (Multipurpose Internet Mail Extension) in one of the types found here when you call shareIntent.setType.
I use the following code to share a image, it's Ok if the image type is png.
But I'm very surprised that it's still OK if the the image type is jpeg. Why? Thanks!
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file://"+arrPath[i]);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
This is how the Intent system works.
http://developer.android.com/guide/components/intents-filters.html#iobjs
An Intent object is a bundle of information. It contains information of interest to the component that receives the intent (such as the action to be taken and the data to act on) plus information of interest to the Android system (such as the category of component that should handle the intent and instructions on how to launch a target activity).
The responsibility of actually dealing with the file is left with the applications that register to handle that kind of intent. At this stage it's not going to care/check whether the file is a jpg or a png.
You're basically saying "hey, sharing applications! I have a png for you!"
I'm not sure what exactly you are after but if you don't want jpgs to be shared you need to handle that in your code.
I succeded in sending an intent to skype and calling whoever i want but now i want to be able to send IM and send files,all done in the background.Is that even possible ? I've looked over their developer page for android,it's kind of poor and doesn't say anything about this.
So,is there any way to do that ?
Thanks in advance and have a nice day !
I have almost succeeded in sending files over Skype using Intents. I am actually using one and the same intent for sending over email or skype, and I let the user choose the app they want to use to send the file. My code is:
File readF = new File(fullFileName);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/*");
intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.send_message_subject) + " " + myList.getName());
intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.send_message_body));
Uri uri = FileProvider.getUriForFile(this, "my.package.fileprovider", readF);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Sending..."));
The File provider I use for sending the file is just like the one explained here: https://developer.android.com/reference/android/content/ContentProvider.html
If you like to send the file explicitly through Skype, and not let the user choose the app maybe you can use something like this:
sharingIntent.setClassName("com.twitter.android","com.twitter.android.PostActivity");
(explained here)
Why I ALMOST succeeded is that the filename is changed when sending over Skype. I haven't figured out how to fix this yet.
Instagram for Android is very limited, from what I have seen so far. My scenario is simple: allow the user to edit a picture and when he clicks on Send:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
Then with queryIntentActivities() I search to see if Instagram is installed. If it is I send the path of my image to be uploaded:
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + path to myfile.png"));
share.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
share.putExtra(Intent.EXTRA_SUBJECT, "Sample subject");
share.putExtra(Intent.EXTRA_TEXT, "Sample text");
share.putExtra(Intent.EXTRA_TITLE, "Sample title");
The result: the image is uploaded using Instagram app (of course if I am logged in), but I can't add a Caption to it. None of the putExtra has any effect. So, is there any way to add a caption as intent parameter ?
And the other question, is it possible to open Instagram app with a certain user name filled in ?
It looks as if Instagram's Android App ignores EXTRA_TEXT, EXTRA_SUBJECT and EXTRA_TITLE, so it seems that adding a caption while uploading an image is not possible. By the way, you can try different approaches to check if it ignores those extras in every case:
OPTION #1: Changing the MIME type.
You are setting the MIME type to "image/jpeg". Try using "image/" or "/*" to check if their app doesn't ignore those extras.
share.setType("image/*");
or
share.setType("*/*");
OPTION #2:
As you are sending multiple MIME types (image and text), maybe their app is expecting ACTION_SEND_MULTIPLE instead of ACTION_SEND.
Intent share = new Intent(Intent.ACTION_SEND_MULTIPLE);
OPTION #3: Use MediaStore.Images.Media.insertImage(ContentResolver cr, String imagePath, String name, String description) function:
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), "file:///" + path to myfile.png", "Sample title", "Sample description")));
share.setType("image/jpeg");
share.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
OPTION #4: Post your issue in their developer forum, although there are similar questions that remain unsolved:
https://groups.google.com/forum/?fromgroups#!searchin/instagram-api-developers/caption$20action_send/instagram-api-developers/PJDuG2sTDlM/6bno5dZmoTEJ
https://groups.google.com/forum/?fromgroups#!searchin/instagram-api-developers/caption/instagram-api-developers/7XUKm9HSAdg/rJbdSnOmXacJ
And don't forget to come back and tell us their answer!
It looks like Instagram has updated their app to accept EXTRA_TEXT to add a caption. If the user has an updated version of Instagram (July 1, 2014 version or later) you can post an image and add a caption with the following code:
Intent instagram = new Intent(android.content.Intent.ACTION_SEND);
instagram.setType("image/*");
instagram.putExtra(Intent.EXTRA_STREAM, [URI of photo]);
instagram.putExtra(Intent.EXTRA_TEXT, [Text of caption]);
instagram.setPackage(instagramPackageName);
startActivity(instagram);
Users with older versions will still get the image, but not have the caption be pre populated.
This code is assuming you have already been through the auth flow.