10
I have two options "select photo" and "take photo" - I have my select photo functionality fully working, but having problems with taking a photo. Mainly having the saved image display in my image view, after its been saved.
Defined my photo location:
public class photoActivity extends Activity {
private String photoPath;
private ImageView imgView;
{...}
My camera listener:
bPicFromCam.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
long captureTime = System.currentTimeMillis();
photoPath = Environment.getExternalStorageDirectory() + "/MYAPP" + captureTime + ".jpg";
getPicFromCam(v);
}
else{
Toast.makeText(getApplicationContext(),
"Sorry there is a problem accessing your SDCard, " +
"please select a picture from your gallery instead.", Toast.LENGTH_LONG).show();
}
}
});
Then my code to start the camera intent (note that the photoPath is correct):
public void getPicFromCam(View view){
System.out.println("photoPath: " + photoPath);
//Outputs the CORRECT location!
try{
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(photoPath);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(Intent.createChooser(intent, "Capture Image"), CAPTURE_IMAGE);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
getString(R.string.exception_message),
Toast.LENGTH_LONG).show();
Log.e(e.getClass().getName(), e.getMessage(), e