-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Sharing the generated image with a share intent #11
Comments
I'm not sure if this should be in react-native-view-shot that should stay minimal. |
Yeah, that's fair. I'll take a look at doing that, thanks! |
@sampurcell93 please see this change: a85cf96 of v 1.3.0 the string returned by the lib used to be like |
that said, you probably still will have to copy somewhere else, not because the file is deleted but because the file is in a private place ATM. not accessible from external (so not from an Intent). public void copy(File src, File dst) throws IOException {
FileInputStream inStream = new FileInputStream(src);
FileOutputStream outStream = new FileOutputStream(dst);
FileChannel inChannel = inStream.getChannel();
FileChannel outChannel = outStream.getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
inStream.close();
outStream.close();
}
public File copyToPublic (File input) throws IOException {
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
dir.mkdirs();
File out = new File(dir, input.getName());
copy(input, out);
return out;
} |
Hi, maybe this is more a general purpose Android question, but I thought perhaps you could help. Since the uri that is generated for a snapshot only exists in the app cache, passing its uri to a share intent always fails. As soon as I change it to a file saved on external storage, it works. Obviously I'd like to avoid doing this, so I'm looking for other ways to achieve this. More than willing to submit a PR. Thanks!
EDIT: My proposal would be an option like {saveToDisk: true} being passed in which would cause the module to call something like
createPermanentFile
instead ofcreateTempFile
, but my native Android fu is limited, so there's probably a better way.The text was updated successfully, but these errors were encountered: