The question is, how do I send a large image (example 720 * 8549) to the WhatsApp without compression and loss of quality.
Is it possible to do this?
Below is the code to send the image that I use:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
File photoFile = new File(imageFile.getParent(), imageFile.getName());
Uri photoURI = FileProvider.getUriForFile(getBaseContext(), getApplicationContext().getPackageName(),
photoFile);
shareIntent.putExtra(Intent.EXTRA_STREAM,photoURI);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, getBaseContext().getString(R.string.photo_share)));
So I send a compressed and unreadable image.
Maybe someone came across a similar.
Good luck to all!
This is not possible because WhatsApp always reduces the size. Google Photos also tried this but if you choose Original when sending over Google Photos the size is still shrinked in the end.
Why do you not take another app like Telegram? You have much more options there.
The easiest way would be to share a link to the original e.g. Google Photos or Dropbox.
Related
I want to share image to snapchat but giving me "Sorry! You can only share images and videos"
I tried this code but doesnt work Android share image on snapchat
I have this intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.setPackage("com.snapchat.android");
int n = Integer.parseInt(number.getText().toString());
Uri uri = Uri.fromFile(new File(db.getimage(n))); //This is retrieving the Uri path from DB
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Open Snapchat"));
the type that you are setting for the setType method is not correct,
if you want to support any format of Image, I suggest you first get the format of Image And after that pass the correct parameter to the setType() method.
for getting a file extension you can use this link:
link
For sharing data in snapchat, there is a kit available in their official website called Creative Kit.
Also you can find the Doc and Tutorials here.
I have an app with different sounds. I'd like to share a sound(audio) together with a text.
If I share only a sound it works:
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory().toString() + "/audio.mp3"));
share.setType("audio/mp3");
startActivity(Intent.createChooser(share, "Share via..."));
Now I tried to add a text:
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory().toString() + "/audio.mp3"));
share.setType("audio/mp3");
sharetext.putExtra(Intent.EXTRA_TEXT,"This should be under the audio file after sharing");
startActivity(Intent.createChooser(share, "Share via..."));
But still only the audio get shared.
How does it works?
And if this isn't possible is there an other way to do this?
Thank you very much! :)
It really depends on what app you end up choosing when you're using the chooser to share the audio file as it's up to the chosen application to decide whether or not to use the supplied text set by EXTRA_TEXT. In short, you really don't have much control over this.
I've been dealing with a problem regarding the sharing of images in an Android app. I've been told it's easier to save the image I want to share in the content provider. I've done that like this: ( don't know if i am doing it right )
File auxFile = new File(getContext().getFilesDir(), imgName);
if (!auxFile.exists()){
FileOutputStream fos = new FileOutputStream(auxFile);
fos.write(bytesDecrypted);
fos.flush();
fos.close();
}
Once that is done I try to share the image through a chooser intent like this:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/jpeg");
Log.v("CachedProvider",CachedFileProvider.AUTHORITY);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + CachedFileProvider.AUTHORITY + File.separator + imgName));
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent,"share"));
In the app I have implemented a method that can receive Images from other apps sharing it ( that part actually work ) so I decided to test my sharing "button" with my own app but it actually don't work.
For the moment I have not set any special provider on my manifest as I don't know if that is necessary.
If further information is needed please feel free to ask.
Thanks you all very much in advance!
Edit:
When I click the "button" a "chooser" between the diferent apps that accept images is beeing displayed. Once I choose the app that I want to share the image with I get no responce.
I recently noticed that when sharing an animated .gif that I generate from my app, the official Twitter app will only share it as a static image.
Previously, I thought everything was working because when I shared the same type of animated .gif with an unofficial Twitter app (Tweetcaster), it properly shared it as an animated .gif.
The thing I'm questioning is whether this is an issue on my end or with the official Twitter app? I ask this because when sharing an animated .gif from the Android Gallery with the official Twitter app, it is also posted as a static .gif.
Here's the code in question:
public void shareGif(String path)
{
File file = new File(path);
Uri uri = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/gif");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "text");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Choose a sharing option"));
}
I was having the same issue as you. I was loading URIs from the drawables and for whatever it was not animating.
I fixed my problem by implementing a custom file provider and loaded GIFs from the assets folder.
Also it was very important to add this flag intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Twitter supports looping GIFs. If your animated GIF doesn’t loop and plays a single time, it will display as a static image.
I am using the easy camera intent for taking simple pictures in Android as follows:
Uri outputFileUri = Uri.fromFile( photo );
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
camera.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
this.startActivityForResult(camera, CAMERA_RESULT);
The problem is: The file is saved twice
Once when the picture is actually taken (then it is saved to the gallery directory)
Once when the user "accepts" the picture (then it is saved to outputFileUri)
Although I really cant imagine this fact I already read about that the creating of those duplicate files cannot be avoided. But if not, is there a possibility to get the path of the picture in the gallery directory to delete it by my app?
Just to let you guys know, I did some research and it is actually not a good idea to solve it like this - unfortunately.
Nevertheless you can do a very easy SurfaceView-Camera-Activity which will only save the data you are telling it to.