I am trying to share GIF image that is stored in resource folder, can I share that GIF Directly or in any other
Uri uri = Uri.parse("android.resource://com.myproject/drawable/xyz.gif");
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.putExtra(Intent.EXTRA_TEXT, "sharing myapp");
shareIntent.setType("image/gif");
startActivity(Intent.createChooser(shareIntent, "Share from"));
use above code but no any app found in chooser to open gif, but in my default photo gallery i can open that gif and also share.
Related
I want to share image on share button click, but in my code not working properly,
shareBtn.setOnClickListener(view -> {
Uri uri = Uri.parse(mImagePath);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share Image"));
});
in my app, I fetching images from gallery, showing in app while sharing image this code working,
How should I share image from my app to another?
I have been trying to share some images to facebook using the ACTION_SEND_MULTIPLE Intent.
The code that i wrote for this is.
ArrayList<Uri> imageUris = new ArrayList<Uri>();
for (DeviceImage image : catchImagesURI) {
Log.d(TAG, "onClickShareFB: image uri " + image.getImageURI());
imageUris.add(image.getImageURI());
}
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setType("image/png");
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
}
where the Uri of the images are /storage/emulated/0/DCIM/Screenshot_1497529599.png and /storage/emulated/0/DCIM/calendar.png
When i choose Facebook from the options i get
Is there something wrong with the format of the Image Uri or am i doing this completely wrong?
Is there something wrong with the format of the Image Uri
They are not valid Uri values. A Uri has a scheme. For example, https://stackoverflow.com/questions/46152988/sharing-to-facebook-with-action-send-multiple is a Uri with a scheme of https. Given the paths that you are using, presumably the scheme should be file.
Whether Facebook can use file Uri values pointing to external storage is a separate matter. Probably it can.
I am very new to this topic how to share my app along with image and text,play store link,my images and text getting from server and image should be not visible after sharing content ,please any one help me how to share this content to other apps like whats app,twitter and more ....
here below my code
File filePath = getFileStreamPath("news_image");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(filePath));
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT,
"Here is my IMAGE");
startActivity(Intent.createChooser(shareIntent, "Share IMAGE Using..."))
You should follow the advice from android documentation.
Snippet from the page:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
In my app, I am opening my image using this code:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(picPathUriString)), "image/png");
startActivity(intent);
I run it on S2 and it opens the picture using the gallery as expected and showing all the capabilities of that gallery app (such as "Share" and "Send" ..etc)
On the S4, it shows the picture but the above options such as SHARE are not there. Although the Gallery on S4 has all the options if opened seperately
WHYYY? How can I make sure I get all the options?
Thanks
Try this....
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
Uri uri = Uri.parse(Uri.parse(picPathUriString));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share via"));
Here is my problem... I want to share a png image. I have the image in drawable and assets. When I use the sharingIntent it works but not in the way that I want. The file shared appears with numbers and without extension and some apps send the message "unknow file". What can i do??
this is my code:
Uri uri = Uri.parse("android.resource://com.example.shareimages/" + R.drawable.caja);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "send"));
I tried to use instead of drawable files, the files in assets ( with this "file:///android_asset/...) but it didn't work
Try something like this:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.setType("image/*");
// For a file in shared storage. For data in private storage, use a ContentProvider.
Uri uri = Uri.fromFile(getFileStreamPath(pathToImage));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(shareIntent)
If you want to share it via the assets folder, you'll have to use a ContentProvider. See this answer on how to do so:
https://stackoverflow.com/a/7177103/1369222