Tuesday, September 14, 2010

[android-developers] Camera App problem

Hi Guys:
I have created app that uses the camera to take an image and write to
my specified path on the SD Card. This appears to work fine in the
emulator giving me the default image.

When I go to test on a real device (Droid by Motorola) my main app is
aborted. From within the debugger, I see the following:

1. Main Activity 1 Starts Activity 2
2. Activity 2 Starts Activity 3
3. Activity 3 decides that a picture must be taken and Starts the
Camera App
1. The Camera app starts up
2. Everything looks fine with the debugger environment, nothing seems
to be wrong
3. Next I point the camera at the object. However the instant I press
the camera shutter to take the picture, the debugger reports the
following:

-------------------------------------------------------------------------------------------
<terminated>MyAppName [Android Application]
<disconnected>DalvikVM[localhost:8602]
--------------------------------------------------------------------------------------------

and from what I see it seems that all activitiess have been killed.
This happens without my pressing the OK button to accept the image
from the Camera app. The proper image (size etc) is captured at the
requested pathname but something is causing my app to die. Please
understand that I am single stepping thru the code so after executing
the instruction to start the activity, I cannot see how any subsequent
instructions in my code could be causing this problem.

Any comments, suggestions will be greatly appreciated as I have been
frustrated by this now for 2 days.
Thanks in advance.

Here are the routines:
_____________________________________________________________________
private void TakePicture () {
String mDirectoryname = null;
Intent cameraIntent;

try {
// Make our directory
File ExternalDir = Environment.getExternalStorageDirectory();
File myDir = new File(ExternalDir,"/Download/MyReceiptImages");
myDir.mkdirs();

// Make the temp file and delete it if it exists
mDirectoryname = ExternalDir.toString() + "/Download/
MyReceiptImages";
File tempfile = new File(mDirectoryname, "0000.jpg");
if (tempfile.isFile()) tempfile.delete();
Uri Imagefile = Uri.fromFile(tempfile);

// Fire up the Camera

cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Imagefile);
startActivityForResult (cameraIntent,
Globals.ACTIVITY_CAMERA);

}
catch (Exception e){
Log.v(TAG, e.toString());
}
return;

}

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);

if (resultCode == RESULT_CANCELED){
return;
}
switch (requestCode) {
case Globals.ACTIVITY_CAMERA:
File ExternalDir =
Environment.getExternalStorageDirectory();
File myDir = new File(ExternalDir,"/Download/
MyReceiptImages");
myDir.mkdirs();

// Make the permanent filename
String mDirectoryname = ExternalDir.toString() + "/
Download/MyReceiptImages";
String filename = "d_" +
String.valueOf(Globals.getCurrentRowId()) + ".jpg" ;
ImageFilename = new File(mDirectoryname, filename);
if (ImageFilename.isFile()){
ImageFilename.delete();
}
File takenFile = new File(mDirectoryname, "0000.jpg");
takenFile.renameTo(ImageFilename);
break;

}
}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate