Share sound in my app - java

My app is a soundboard and I want it is possible that you can share the sounds. This is my code which does not work.
final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("audio/mp3");
shareIntent.setPackage("com.whatsapp");
Uri recurso = Uri.parse("android.resource://" + PACKAGE_NAME + "/raw/" + R.raw.a);
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, recurso);
startActivity(Intent.createChooser(shareIntent, getString(R.string.text1)));
But the sound can not be sent. What do you have to use as a path where does it have to lead?
pls help me

Related

How can I send audio files from my app to Whatsapp?

I'm working on an app from which you can send audio to whatsapp. However, the codes that I am using are not working.
//This code returns an error and asks to try again to send the audio file
String sharePath = Environment.getExternalStorageDirectory().getPath()
+ "android.resource://"
+ wspActivity.this.getPackageName() + "/raw/" + "increible";
Uri uri = Uri.parse(sharePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.setPackage("com.whatsapp");
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Sound File"));
//This code indicates that the file is of an incompatible type.
final Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/mp3");
final String path = copyFiletoExternalStorage(R.raw.increible, "increible.mp3");
final Uri soundUri = Uri.parse(path);
share.putExtra(Intent.EXTRA_STREAM, soundUri);
startActivity(Intent.createChooser(share, "Compartiendo..."));
If anyone has any idea why this behaviour, I would appreciate it if you could share it :)
I need to improve some of these codes to be able to send audio files from my app through whatsapp

Image sharing to the other application by Intent

I am making an app and I wanna share images from my app to a specific app
so i used this code to share via choose
try {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
// path of image
final String imageURIPath = "image-path";
Uri imageURI = Uri.parse(imageURIPath);
sharingIntent.setType("image/jpeg");
sharingIntent.setType("image/jpg");
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, imageURI);
startActivity(Intent.createChooser(sharingIntent, "Share via app"));
} catch (Exception e) {
showMessage(e.toString());
}
and all work perfectly but I need to share to a specific app like this
shareIntent = getPackageManager().getLaunchIntentForPackage("app_PackageName");
startActivity(shareIntent);
so 'app_PackageName' chage to like app what i need like this example
shareIntent = getPackageManager().getLaunchIntentForPackage("com.adobe.lrmobile");
startActivity(shareIntent);
and I build the app without errors but when I wanna share to that app it just opens that app

GIF is getting shared as an image not animated - Android Java

I am trying to share an GIF programmatically, but it is getting shared as an image (not animated)
Code Snippet:
Intent shareIntent = new Intent();
shareIntent.setType("image/gif");//image/gif
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(myList.get(item)));
startActivity(Intent.createChooser(shareIntent,"Share gif"));
You are trying to share to which apps?
Some whatsapp builds don't support gif feature.
You can check this question here with some additional information: How to share GIF image in Whatsapp programmatically in Android?
There is this comment:
"This solution doesn't work with whatsapp but does work with all the other apps I specified above (namely Hangouts, Android Messages, Facebook Messenger)"
He is referring to this answer:
private void ShareGif() {
// replace the path and file name with your gif image path and name
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String fileName = "temporary_file.gif";
File sharingGifFile = new File(baseDir, fileName);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/gif");
Uri uri = Uri.fromFile(sharingGifFile);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share image"));
}
/*
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.whatsapp");
shareIntent.putExtra(Intent.EXTRA_TEXT,title + "\n\nLink : " + link );
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(sharePath));
shareIntent.setType("image/*");
startActivity(shareIntent);
*/
Hope it helps.

Share intent in Android not sharing image to any app (after popup)

I am trying to share image by using share intent in Android. That showing list of installed apps after button click. But I select any one app it's not sharing. The opening app crashed or some app told sending this content type not support
My code:
Intent share = new Intent(Intent.ACTION_SEND);
File filepath = Environment.getExternalStorageDirectory();
File dir = new File(filepath.getAbsolutePath() + "/");
dir.mkdirs();
Uri uri = Uri.parse(dir+"/img.jpg");
share.putExtra(Intent.EXTRA_STREAM,uri);
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
share.setType("image/jpg");
startActivity(Intent.createChooser(share, "Share Image"));
and also I am giving permission for read and write external storage.
Log Cat:
I got this error repeatedly:
07-06 12:25:11.654: E/SurfaceFlinger(113): SurfaceFlinger translucent=1 isOpaque=0 isExternalDisplayLayer=0 isExternalBlockLayer0
Try This:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
startActivity(Intent.createChooser(shareIntent, "Share image using"));
http://developer.android.com/training/sharing/send.html

Is there any way to post multiple image on google plus using ACTION_SEND

I am working on an Android App in which I am fetching images from Url. I have to share more than one image on Google+. One image is working fine. Please suggest.
I am using following following peace of code.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, curentWit.getWit_name());
shareIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(shrd).toString());
if(isInLine == 1)
{
shareIntent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
}
shareIntent.setType("text/plain");
startActivity(shareIntent);
I don't know if GooglePlus lets you send multiple images simultaneously. But if you want to send multiple images at same time(suppose you are emailing) then you should make use of Intent.ACTION_SEND_MULTIPLE instead of Intent.ACTION_SEND
This is how I sent multiple images via email.
Intent shareIntent = null;
if(uris.size > 1) {
shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
}
else {
if (uris.size() == 1) {
shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
}
}
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, curentWit.getWit_name());
shareIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(shrd).toString());
startActivity(shareIntent);

Categories