In my app, I open the camera and want to save that file with a specific name.
I use this code:
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File("new-photo-name.jpg")) );
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
protected void onActivityResult1(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
Bitmap image = (Bitmap) data.getExtras().get("data");
}
}
It does open the camera, I can take and save the photo, but it does not give the good name.
Everytime when I save the picture, he gives the picture an other name, 1 name example is: “13333675392558.jpg”. I don’t understand how he comes with that kind of numbers.
Why does my code does not apply the name: “new-photo-name.jpg” ?
And/Or what do I wrong then?
Thanks already, Bigflow
I got it working, but don’t know the exact same problem yet, but this code worked for me:
onLongPress has something to do with gesture (touch) actions, you could also use a button here.
Really small code, but works like a charm