Uri uri = Uri.parse("android.resource://haydo.kufurbaz.kfrbazhaydosesleri/raw/oylemikesiliramk.wav");
Intent myınIntent = new Intent(Intent.ACTION_SEND);
myınIntent.setType("audio / wav");
String sharebody = ".mp3";
myınIntent.putExtra(Intent.EXTRA_STREAM,uri);
startActivity(Intent.createChooser(myınIntent,"Share using"));
return true;
When i try to send someone audio to whatsapp it does not shown in format of wav or mp3 it
my file name in raw is : oylemikesiliramk.wav
help pls
Related
I have stored a video file in the android raw folder and want to share it through WhatsApp. But I am getting the file in WhatsApp as null.bin.
private void shareVideo(){
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/raw/video_name");
Intent videoshare = new Intent(Intent.ACTION_SEND);
videoshare.setType("*/*");
videoshare.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
videoshare.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(videoshare);
}
I am working audio recording app, in which the audio is recorded and stored inside the app and that path is stored in SQLITE.
I need that audio file to be shared in whatsapp/gmail or saved in internal directory of mobile.
I try to share them using the Intent but in whatsapp it showed unsupported format.
I tried this code
private void Shareoption(List<RecordData> uploadlist)
{
RecordData reco2 = uploadlist.get(0);
String id3 = reco2.getId();
final RecordData recordData = DBcreatedata.getData(id3);
final File f;
locname = recordData.getRecordDataTitle();
f = new File(recordData.getRecordData());
Uri uri = Uri.parse(f.getAbsolutePath() );
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, uri.toString());
startActivity(Intent.createChooser(share, "Share Sound File"));
And I also searched about this and I came to know that first the audio file must be stored in internal directory before sharing. So I tried input output stream method, it did not work.
Can any one help me to share this audio file ?
By using this I think your problem will be solved
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri shareFileUri= Uri.parse(string);
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sharingIntent.setType("*/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, shareFileUri);
sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(sharingIntent, "Share Sound File"));
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
In my app there is a feature where the user can share a video with the app of their choice. The code is fairly straightforward (where mediaPath is a variable of type String which is a path to a valid video):
File media = new File(mediaPath);
Uri uri = FileProvider.getUriForFile(context, getString(R.string.file_provider_authority), media);
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("video/*");
String title = getString(R.string.share_video_title);
Intent chooser = Intent.createChooser(share, title);
if (share.resolveActivity(context.getPackageManager()) != null) {
startActivity(chooser);
}
Sharing works perfectly on gmail (for example) and seems to work fine on whatsapp as well. It compresses the video and uploads it. The recipient gets the video and is able to see a thumbnail and download it. However they cannot play the video.
I finally found the solution is here
public void shareVideoWhatsApp() {
Uri uri = Uri.fromFile(v);
Intent videoshare = new Intent(Intent.ACTION_SEND);
videoshare.setType("*/*");
videoshare.setPackage("com.whatsapp");
videoshare.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
videoshare.putExtra(Intent.EXTRA_STREAM,uri);
startActivity(videoshare);
}
Refrence
Are you try this:
String path = ""; //should be local path of downloaded video
ContentValues content = new ContentValues(4);
content.put(MediaStore.Video.VideoColumns.DATE_ADDED,
System.currentTimeMillis() / 1000);
content.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
content.put(MediaStore.Video.Media.DATA, path);
ContentResolver resolver = getApplicationContext().getContentResolver();
Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("video/*");
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "Hey this is the video subject");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Hey this is the video text");
sharingIntent.putExtra(Intent.EXTRA_STREAM,uri);
startActivity(Intent.createChooser(sharingIntent,"Share Video");
I write the code like this. Also path is correct. But Facebook messenger can't hold my .wav file
String sharePath = "/storage/emulated/0/Recordings/test.wav";
Uri uri = Uri.parse(sharePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/wav");
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Sound File"));
https://developers.facebook.com/docs/messenger/android
audio/wav is not a supported MIME TYPE. Check the above link for supported types