Here is my code. After I using the phone to take image, I save to a
file. Then I want to use imageview to display the image. But it
failed. I checked that the file is saved correctly in SD card. I use
mImageView.setImageURI(mImgUri) to display image. anything wrong?
public void save()
{
try
{
File sdDir = Environment.getExternalStorageDirectory
();
if(!sdDir.canWrite()) // Workaround for broken sdcard
support on the device.
sdDir = new File("/sdcard/sdcard");
try
{
Date now = new java.util.Date();
String fileName = sdDir + Common.BASE_DIR
+ SharedConstants.sDateFormater.format
(now) + ".png";
mStoredPic = new File(fileName);
FileOutputStream fileOutputStream = new
FileOutputStream(mStoredPic);
fileOutputStream.write(mRawData);
fileOutputStream.close();
mImgUri=Uri.fromFile(mStoredPic);
Common.mImageHasContent=true;
}
catch(IOException e)
{
}
mImageView.setImageURI(mImgUri);
mImageView.bringToFront();
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---