Two things:
1) Make the file accessible to Gallery by placing it in the "external
storage" (memory card or its equivalent).
Use Envrionment. getExternalStoragePublicDirectory() or appropriate
methods from earlier API levels to determine the directory where your
image should be saved.
<http://developer.android.com/guide/topics/data/data-storage.html#SavingSharedFiles>http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
2) Notify Gallery about the new image:
http://developer.android.com/reference/android/media/MediaScannerConnection.html
-- K
On 05/22/2012 11:38 PM, Mark wrote:
I gave a Galaxy Nexus running 4.04 version of Android. I am trying to
save a photo from my App so it can be viewed in the gallery. How can I
do this? The code below writes to the log that the photo is saved, but
I cannot see it on the device when I search for it.
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
FileOutputStream outStream = null;
try {
// Write to SD Card
outStream = new FileOutputStream(String.format("myfile.jpg",
System.currentTimeMillis()));
outStream.write(data);
outStream.close();
Log.d(TAG, "onPictureTaken - wrote bytes: " + data.length);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
}
Log.d(TAG, "onPictureTaken - jpeg");
}
};
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en