Image file names

Hi,
Ive been playing around with the camera function and have a few questions.

I took a few photo's earlier with the default AI2 camera and they were automatically named, something like "app_inventor_1613217757666.jpg" what convention is used for the number section of the filename ?

What would be the best / easiest method to create a similar unique number for naming photo's in a similar way if they were not already named with a unique identifier ?

Cheers
Steve

What naming convention do you want to use ? The world is your oyster here....

Thats why I asked what the convention used by AI2 was, to give me some food for thought.

The date with the exact time will be unique.

Taifun

Taifun thanks for that, is there a simple way to implement that convention.
Would have been a nice touch if you'd used that or something similar in your camera extension, its the default name im trying to get changed.

Cheers
Steve

I need SAVE AND RENAME NAME OF IMAGE ! PLEASE HELP - #10 by Sergei_Kiev allows you to rename the captured image anything you want.

The following information might be what you need to change the default name in an extension you code:

This link Camera API  |  Android Developers shows the code recommended to work with the device's default camera.

The Java code to provide a unique file name for each image that Google recommends is

// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE){
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ timeStamp + ".jpg");

just use the Clock component together with the GetMillis and Now method
http://ai2.appinventor.mit.edu/reference/components/sensors.html#Clock

Taifun

The GetMillis and Now method worked perfectly ... just what i needed.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.