Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(
Uri.parse("file://" +file.getAbsolutePath()),"image/*");
startActivity(intent);
I want to display image with share, delete and set as functionality using android intent . but my image is opening without share option......... How to show image with share options?
By Default it wont show the options with share and delete. But You can do this manually with Intent and File.
try following code for share image
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file));
startActivity(Intent.createChooser(share, "Share image using"));
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 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.
Hi I want to share both text and pdf file at a time in whats app,How it can be done.currently i can share any one of them at a time.
I have tried this but its not working.
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.setType("application/pdf");
share.putExtra(Intent.EXTRA_TEXT, "My sample image text");
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setPackage("com.whatsapp");
startActivity(shareIntent);
The question is (might be a repeated one), but I could not find a proper answer to it, so asking here again.
In my application, I need to share both an image and a text file using a single intent.
I read a few answers, like:
ACTION_SEND sending both an Image and Text in the same Intent,
Send Image and Text both using ACTION_SEND or ACTION_SEND_MULTIPLE
and also Problems sharing combined text and image with SHARE INTENT
and tried to implement the given solutions in my application, but none of them worked for me.
The code I've implemented so far is as below :
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_SUBJECT, "I found movie "+movieTitle+" on Movies Tracker!");
share.putExtra(Intent.EXTRA_TEXT, "my text");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
share.setType("image/*");
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(share, "Share via"));
So now my question is: is there any way to share both an image and a text file with single intent?
If it's possible, then please help regarding this issue.
Thanks in advance.
try this one
private void initShareIntent(String type,String _text){
File filePath = getFileStreamPath("<span class="skimlinks-unlinked">shareimage.jpg</span>"); //optional //internal storage
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, _text);
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath))); //optional//use this when you want to send an image
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
}
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"));