We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've been reading the android documentation about this feature, here, and I was trying to think about how to share a saved frame with an Intent instance. Any step or tip is welcome in order to read more about it. I guess this could be a nice question, not just for me but for anyone.
This is the basic part. I'm not sure if the saved frame should be converted to uri, or there is another way to do it.
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));
Answers
ok, I've got something more. The Intent Chooser works, although a grey image is attached, as it has no information. I'm not sure if I'm doing well with the URI.
My best guess is that the file
9ume.png
is stored in thedata
folder, while the functiongetFileStreamPath()
is searching the app's private directory (thesketch
folder), although I may be wrong. You can (probably) check for this by printing out the URI's actual file location.I'll check it out calsign, thanks!
println(uri.getPath())
prints "/data/data/processing.test.imagen/files/9ume.png"It seems right, but doesn't work. I've tried with external files in sdcard and works!
By the way, I don't know why when saving a file to Pictures directory it doesn't show up in the Gallery, but I can see it within the File Manager.
i.e
EDIT1:
After spending hours searching, I've tried adding startBroadcast(intent) and console throws "processing.app.SketchException: cannot find symbol" at that line. (I've already imported
android.content.Context
andandroid.content.Intent
)sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));
EDIT2:
EDIT1 worked.
The
data
folder appears twice in the file's path. Is this intentional?You might try getting the full path of the file and (if your device is rooted), you can then navigate to that file. Of course, this isn't an option if your device isn't rooted...
EDIT: It wasn't clear... but were you able to get it to work? I can't tell from your string of edits...
/data/data
is strange but it's an Android convention. To access there the phone must have been rooted, you're right.In "EDIT2" I commented that what I posted in "EDIT1" worked 8-X
I'm not sure why I was having that error.
Here's the code working,
The Animated Gif Encoder is a ported version of the original one.