I would like to ask if anyone knows how to attach an image directly to a send email portal instead of opening up the gallery for users to select?
Thanks a lot.
use the below code
File file = new File(Environment.getExternalStorageDirectory(),"image.png");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+file));
startActivity(Intent.createChooser(intent, "Share Picture Via Email"));
Related
I'm trying to make refer and earn activity in my appSo I want to permanently display a few apps like whatsapp, etc for the user to click on them and share directly.I'm using Intent to share the referral code but it pops up the apps list when the user clicks share.The code I'm using is,
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is a message");
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "Share via"));
How can I make the app chooser permanent for a few apps?
The app chooser is not intended to be displayed permanently. Therefore you will have to create simple buttons or icons and create an intent that refers to the desired app directly, by setting the package of the intent.
E.g. to share sth with WhatsApp use sth like this:
Intent sendIntent = new Intent();
// here comes the magic
sendIntent.setPackage("com.whatsapp");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Depending on the type of content you want to share and the apps you want to share with, it makes sense to reuse the code to create the intent and just set the respective package and eventually some additional parameters.
You will need package name of app and a Intent.
change ACTION_VIEW to ACTION_SENDTO
set the Uri as you did set the
package to whatsapp
Intent i = new Intent(Intent.ACTION_SENDTO,
Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
i.setType("text/plain");
i.setPackage("com.whatsapp"); // so that only Whatsapp reacts and not the chooser
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
i.putExtra(Intent.EXTRA_TEXT, "I'm the body.");
startActivity(i);
You can refer this link for More:
Send text to specific contact (whatsapp)
Sending message through WhatsApp
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.setPackage("com.whatsapp");
intent.putExtra(Intent.EXTRA_TEXT, "your text content");
startActivity(intent)
I am facing same problem for share tamil font content in Whatsapp. I found the solution, this setType("*/*") share full content.
I am very new to this topic how to share my app along with image and text,play store link,my images and text getting from server and image should be not visible after sharing content ,please any one help me how to share this content to other apps like whats app,twitter and more ....
here below my code
File filePath = getFileStreamPath("news_image");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(filePath));
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT,
"Here is my IMAGE");
startActivity(Intent.createChooser(shareIntent, "Share IMAGE Using..."))
You should follow the advice from android documentation.
Snippet from the page:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
The image is an url, like http://www.example.com/123/abc.jpg
I want to share some text and an image with other app.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, String.format(getResources().getString(
R.string.share_text), pid));
intent.setType("image/jpg");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("http://www.example.com/123/abc.jpg"));
startActivityForResult(Intent.createChooser(intent, "Share with"),
Settings.SHARE_REQUEST);
But it is not work. It seems like the uri should be a local image? If this is true, how can I convert the image url to a local uri? Thanks!
See this page for details on sharing. You should not need to call startActivityForResult(). Just call startActivity() and it will properly prompt the user for where to send the data (i.e. pick Gmail, browser, etc.)
I could understand from various post that it is not possible to share both the image and text data in Facebook through intent share. But Twitter is able to share both thumbnail and text in Facebook through intent share which is shown in the image. SO can u comment on this and suggest a way to share both image and text in Facebook through intent.
Thanks in advance.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_TEXT, viewProject.getShareLink());
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "compatible apps:"));
Anyone knows how to attach images with
Intent intent = new Intent(Intent.ACTION_SENDTO);
I know how to do it with Intent.ACTION_SEND, but i would like to use SENDTO to remove the Bluetooth option for the user.
What i have works fine when not attaching the picture but when i use
intent.setData(pictureUri);
It tells me that there isn't any application to do the job.
Thank you for your help.
EDIT
Inserted the code that I have now. It "works fine" except that the image isn't getting attached.
Code
intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/html");
Uri uri = Uri.parse("mailto:?");
intent.setData(uri);
intent.putExtra(Intent.EXTRA_STREAM, picture);
intent.putExtra("subject", subject );
context.startActivity(Intent.createChooser(intent, "Share Via:"));
The picture is a Uri for a picture on the phone.
Anyone knows what can be the problem?
Try:
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pic));
According to the API docs, SENDTO expects a recipient in the data field, not an attachment.
By saying intent.setData(pictureUri), you're basically trying to send a message to the picture. See here.
SEND accepts attachments via extras, so you could try the same for SENDTO.
For example:
intent.putExtra(Intent.EXTRA_STREAM, pictureUri);