I have created an app that uses the ACTION_IMAGE_CAPTURE intent 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 fires the
ACTION_IMAGE_CAPTURE intent
1. The Camera Activity 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.
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;
}
}
I am sure (I hope) that it is something simple but I just cannot spot
it. It seems to be related to memory usage. My app has been running
for about 4 months. This started recently when I introduced the
Camera. Why android is killing the entire app is beyond me.
HHHHHeeeeeeellllpppp somebody please!!!!.
--
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