I want to share my csv file to any action like Bluetooth, send to email ,etc
final String filename = Environment.getExternalStorageDirectory() + "/Folder" + "/" + "mycsv.csv";
Intent sharingIntent = new Intent();
sharingIntent.setAction(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM, filename);
sharingIntent.setType("text/comma_separated_values/csv");
startActivity(Intent.createChooser(sharingIntent, "share file with"));
the output will be no request containt no data
I think that the filename requires a file:// prefix. Android, for sharing any types of file requires a universal identifier or a Uri.
final String fileUriString = "file://" + Environment.getExternalStorageDirectory() + "/Folder" + "/" + "mycsv.csv";
Also, change the type to text/csv.
Intent sharingIntent = new Intent();
sharingIntent.setAction(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse( fileUriString ) ) ;
sharingIntent.setType("text/csv");
startActivity(Intent.createChooser(sharingIntent, "share file with"));
See this answer for more.
Related
i want to share audio file with social media like whatsapp,drive,gmail,etc.
i tried this code,
after i click on the whatsapp icon i get the massage:
"the file format is not supported"
after i click on the gmail icon i get the massage:
"Couldnt attach file"
//sharePath: my audio path file
String sharePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + songNameAndDateArray.get(newI).getSongName().toString() + "FinalSongRec" + "File" + "AudioRecording.3gp";
File f = new File(sharePath);
Uri uri = Uri.parse(f.getAbsolutePath());
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("audio/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent,"share audio");
Check following code
String sharePath = Environment.getExternalStorageDirectory().getPath()
+ "/Soundboard/Ringtones/custom_ringtone.ogg";
Uri uri = Uri.parse(sharePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Sound File"));
I found this answer from following link Sharing audio file
Below this code i try to share text with video but it only share video,text not share with video.
please help if any one have solution of my issue.
String path="android.resource://" + "com.avani.videoviewdemo" + "/" + R.raw.ae_kaash_kahi;
//Intent a = getIntent();
file=new File(path);
str=arrayList.get(position).getVideoName();
Log.e("video_name", ""+arrayList.get(position).getVideoName()); Log.e("video_name",""+ str);
id = context.getResources().getIdentifier(str, "raw", context.getPackageName()); Uri uri = Uri.parse("android.resource://" + context.getPackageName() + "/" + id);
DownloadFile();
Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri screenshotUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file); sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); sharingIntent.putExtra(Intent.EXTRA_TEXT, "From FullScreenVideoStatus"); sharingIntent.setType("video/*"); context.startActivity(Intent.createChooser(sharingIntent, "Share video using"));
For set caption in video/image in share intent, just set text in:
sharingIntent.putExtra(Intent.EXTRA_TITLE, "Your text caption");
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("video/mp4"); //If it is a 3gp video use ("video/3gp")
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/raw/ae_kaash_kahi";
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Video Title");
startActivity(Intent.createChooser(sharingIntent, "Share Video!"));
intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "TEMPORARY"); // for text share
intent.putExtra(Intent.EXTRA_STREAM, uri); // for media share
intent.setType("image/*"); // this line is use to filter which app support specified media formate to share
startActivity(intent);
you can use video/* for video file here i have used image/* for image share
I am not able to share audio file in whatsapp if there is any whitespace in the filename. But it works when sharing using email client. For filenames without spaces also it works fine. Below is the code which I am using
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
File F = new File(filePath);
F.setReadable(true, false);
Uri fileURI = Uri.fromFile(F);
Log.e("Share", "Share file url is " + fileURI);
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Shared file");
sharingIntent.setType("*/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, fileURI);
I tried doing filePath.replace(" ", "\ "), not working.
What changes should be done to share the file?
This works when you trying to share with WhatsApp an audio file with whitespace:
String filePath = "file:///sdcard/Download/example attachment.mp3";
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));
shareIntent.setType("audio/*");
startActivity(Intent.createChooser(shareIntent, "Share audio file"));
I was able to share audio using same code as I have posted with just a minor change in the type. Below code works for both email as well as whatsapp sharing:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
File F = new File(filePath);
F.setReadable(true, false);
Uri fileURI = Uri.fromFile(F);
Log.e("Share", "Share file url is " + fileURI);
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Shared file");
sharingIntent.setType("audio/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, fileURI);
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).
Hi i am developing an android application with email functionality. Here i need to send a CSV file from my path data/data/mypackage/files folder. I am storing the csv file there.It is saving there good.My csv file size is just 245 bytes only. But when i tried to send that file throught mail functionality of android is displaying "File too Large to attach.." message is displaying.
Here is my code:
String filelocation="file:///data/data/my package/files/excerDB.zip";
final Intent emailIntent = new
Intent(android.content.Intent.ACTION_SEND);
emailIntent .setType("plain/text");
emailIntent .putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"purpletalk.raghu#gmail.com"});
emailIntent .putExtra(android.content.Intent.EXTRA_SUBJECT, "Attendence Report");
emailIntent .putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse(filelocation));
startActivity( emailIntent);
But it is not working for me. Please advice me how can i send my file as a attachment to mail in my application.
i hope this code will help u
String FILE = Environment.getExternalStorageDirectory() + File.separator
+ "Foldername";
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
// sendIntent.setType("text/html");
sendIntent.setType("application/csv");
sendIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "");
sendIntent.putExtra(Intent.EXTRA_TEXT, "");
String temp_path = FILE + "/" + "Filename.csv";
File F = new File(temp_path);
Uri U = Uri.fromFile(F);
sendIntent.putExtra(Intent.EXTRA_STREAM, U);
startActivity(Intent.createChooser(sendIntent, "Send Mail"));
Enjoy this code!