i want to share video from my application. It is giving option and when i select gmail. I am getting mail but there is no video in it. the code is as follow. can some one tell me what i did wrong in it ?
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
String path="/mnt/sdcard/DCIM/Camera/VID_19800115_233308.3gp";
Uri videoUri = Uri.parse(path);
sharingIntent.setType("video/*");
Log.i(TAG, "::onClick:" + "videoUri"+videoUri);
sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri);
startActivity(Intent.createChooser(sharingIntent, "Share Video using"));
Related
I made an implementation of share video and all works when I share video by WhatsUp. But I noticed that if I share video by Slack it doesn't play in Slack. It means I got the video file in my Slack account, click on it and it doesn't play... I can download this video and it will play, but in Slack it doesn't.
If I share a video from standard Gallery app to Slack it works...
So, what is the difference?
Here my sharing code
private fun openShareDialog(iC: Context, //
iPath: String) {
MediaScannerConnection.scanFile(//
iC.applicationContext, //
arrayOf(iPath), null //
) { _, iUri ->
var shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.type = "video/*"
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "title")
shareIntent.putExtra(Intent.EXTRA_TITLE, "title")
shareIntent.putExtra(Intent.EXTRA_STREAM, iUri)
shareIntent = Intent.createChooser(shareIntent, iC.getString(R.string.tetavi_send_to))
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
iC.startActivity(shareIntent)
}
}
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
sharingIntent.putExtra(Intent.EXTRA_TITLE, "title");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
startActivity(Intent.createChooser(sharingIntent, "share file with"));
I am try to send pdf file from my app to whatsapp, and here is the code,
but something missing!!
it opens whatsapp and i can choose a contact but it says "sharing failed"!
the code
String PLACEHOLDER = "file:///android_asset/QUOT_2016_10(test).pdf";
File f = new File(PLACEHOLDER);
Uri uri = Uri.fromFile(f);
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_TEXT, "hi");
share.setPackage("com.whatsapp");
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("application/pdf");
activity.startActivity(share);
I figured out the problem, and here is the answer if somebody had the same issue. The problem was that I am trying to open the pdf from the asset folder which did n't work, and if would try to open the pdf from the download folder for example, it would work. Please refer to the the code below for the final correct way:
File outputFile = new File(Environment.getExternalStoragePublicDirectory
(Environment.DIRECTORY_DOWNLOADS), "ref Number from Quotation.pdf");
Uri uri = Uri.fromFile(outputFile);
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.setType("application/pdf");
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setPackage("com.whatsapp");
activity.startActivity(share);
File outputPath= new File(Environment.getExternalStorageDirectory() + "/MyPdf/example.pdf");//change with your path
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("application/pdf");
Uri fileUri = FileProvider.getUriForFile(getApplicationContext(),
getPackageName() + ".fileprovider", outputPath);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
startActivity(Intent.createChooser(shareIntent, "Share it"));
It's technically wrong, what if someone has WhatsApp business or want to share file on gmail then use this...
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, _text);
shareIntent.putExtra (Intent.EXTRA_STREAM, Uri.parse(_file));
startActivity(Intent.createChooser( shareIntent, "Share"));
In this u just have to add text and file
Text u attach will become subject in gmail and if you are sharing image on WhatsApp then text will become as image caption
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/
I am using the following code to share image to facebook but its not working.
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/png");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("/sdcard/img1.png"));
startActivity(Intent.createChooser(share, "Share Image"));
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"));
One, it should be in this order just for readability and sensical reasons
you need to say what the error is...
NEVER hardcode the path to the image '/sdcard/img1.png' use getExternalStorageDirectory() instead
I'm trying to use the ACTION_SEND_MULTIPLE intent to share at the same time a video file and a text.
Now, this works in GMAIL (video in the attachments and text in the body of the mail), however I want to do the same in Whatsapp too, but it doesn't appear in the list of apps of the intent.
My code is the next:
Intent sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Descarga la app en...");
ArrayList<Uri> contenidos = new ArrayList<Uri>();
File file = new File(Environment
.getExternalStorageDirectory()
.getAbsolutePath()
+ "/Talking/"
+ nombreVideo
+ ".3gp");
Uri screenshotUri = Uri.fromFile(file);
contenidos.add(screenshotUri);
//sharingIntent.putExtra(Intent.EXTRA_STREAM,screenshotUri);
sharingIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, contenidos);
sharingIntent.setType("video/3gpp");
startActivity(Intent.createChooser(sharingIntent, "Share video using"));
Thanks for your help.
Now your code gonna work due the new updates to whatsapp, before this didn't accept this kind of intent (ACTION_SEND_MULTIPLE) because it accepts only one file at a time.
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
shareIntent.setType("image/png");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM,
Uri.parse("file:///mnt/sdcard/UserImages/"+ ParseUser.getCurrentUser().getObjectId() + ".png"));
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Hello test");
startActivity(Intent.createChooser(shareIntent,"Share"));
This probably means Whatsapp does not support this kind of intent (ACTION_SEND_MULTIPLE).