I'm using this code to share content ( Image from URL and text ). but this is not working properly. I'm getting no error, but it's not sharing (I'm trying to share in WhatsApp and GoogleDrive).
Uri imageUri = Uri.parse("http://2805messa.8.2.f.unblog.fr/files/2008/03/elmahdia.jpg");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, post.getPost_text());
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
intent.setType("image/jpeg");
v.getContext().startActivity(intent);
I've already seen the other related posts, but I couldn't find an answer to my question.
Add the flag : FLAG_GRANT_READ_URI_PERMISSION. Also check for internet permissions.
Modified code:
Uri imageUri = Uri.parse(path);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, post.getPost_text());
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
intent.setType("image/jpeg");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
v.getContext().startActivity(intent);
Related
Can't attached image in Facebook and other social service and also set XML file
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:name="android.permission.READ_EXTERNAL_STORAGE"
java file
Uri imageUri = Uri.parse("/sdcard/fildername" + images29.png);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent , "Share"));
You have to write like below.
Uri imageUri = Uri.fromFile("/sdcard/fildername" + images29.png);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent , "Share"));
I'm trying to send an multimedia message(with an image) through an intent.How should I build the intent?
I've tried the code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
I can select mms app(Textra) from chooser dialog to send the image. But the chooser dialog lists other apps(such as Google Keep).
Then I tried this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
Only mms apps appears now.But I don't know how to attach my image.
Is there any solution for that?
try this may help,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
intent.putExtra("sms_body", "write some text here");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/whatever.png")));
intent.setType("image/*");
startActivity(intent);
Try this way,hope this will help you to solve your problem.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "some text");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
intent.setType("image/png");
startActivity(intent);
I have video url, from which I parse to to get the uri. I try to pass the uri in share, but I don't see the video being shared.
Uri uri = Uri.parse(url);
Intent sharingIntent = new Intent(
Intent.ACTION_SEND);
sharingIntent.setType("video/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM,uri
);
startActivity(sharingIntent);
Am I missing something here, or should I save the uri to external storage and then pass it?
Also I need to know how to save the video using the uri to Gallery.
use this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("video/mp4");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path)));
startActivity(Intent.createChooser(intent, "share"));
"path" is your videos pass like /sdcard/mVideo.mp4
Intent.createChooser seems to be missing. Please see the code snippet and the link.
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(path);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
The link:
http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent/
Here i am sharing images from my app to whatsapp.but this code is working here only for mylist1[i] and not for mylist2[i] and mylist3[i]. As in my activity file there are 15 images in every list. what to do?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
Uri uri = Uri.parse("android.resource://com.example.drawcelebrities/"+mylist1[i]+mylist2[i]+mylist3[i]);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share via"));
Take image array in mylist[] and use below code, then share image via whatsapp.
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+mylist[i]);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share via"));
If I'm not wrong then for that you should use android.content.Intent.ACTION_SEND_MULTIPLE..Refer this link it will help you..
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files.");
intent.setType("image/jpeg");
ArrayList<Uri> files = new ArrayList<Uri>();
for(String path : filesToSend /* List of the files you want to send */) {
File file = new File(path);
Uri uri = Uri.fromFile(file);
files.add(uri);
}
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
startActivity(intent);
How can I share images using intent chooser. I have tried
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/png");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse(url));
where url is from internet
I am able to share text using the above code the image doesnt get attached.
try doing this instead i think it will work
Uri uri = Uri.fromFile(new File(filename));
share.putExtra(Intent.EXTRA_STREAM, uri);