I am using Android 4.03 on a Samsung Galaxy Nexus. The logs are showing
that the file has been written to the phone memory, however when I check in
windows explorer or using the phones gallery I cannot see the image that I
have just taken a photo of.
Here is my code.
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
FileOutputStream outStream = null;
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
mExternalStorageAvailable = mExternalStorageWriteable = true;
Log.d(TAG, "Can Write ");
try {
outStream = new FileOutputStream(String.format("/sdcard/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 {
}
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
Log.d(TAG, "Cant Write ");
} else {
// Something else is wrong. It may be one of many other states, but all
we need
// to know is we can neither read nor write
mExternalStorageAvailable = mExternalStorageWriteable = false;
Log.d(TAG, "Other Error ");
}
}
};
--
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