Ok later some try i made this.
GOOGLE EXAMPLE
String mCurrentPhotoPath;
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
// Save a file: path for use with ACTION_VIEW intents
mCurrentPhotoPath = "file:" + image.getAbsolutePath();
return image;
}
WHAT I MADE
'GET FILE NAME, LIKE ANDROID API DOCUMENTATION
Sub GetFileName As String
DateTime.TimeFormat = "yyyyMMdd_HHmmss"
Private timestamps As String = DateTime.Time(DateTime.Now)
Private imageFileName As String = "JPEG_" & timestamps & "_.jpg"
Return imageFileName
End Sub
the google code, create a temp file where will be saved the picture, i dont know make this in b4a, i made the code only to return the filename.
OK, later i need invoke the camera like google show on the code. (here i need some help)
GOOGLE EXAMPLE
static final int REQUEST_TAKE_PHOTO = 1;
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
...
}
// Continue only if the File was successfully created
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(this,
"com.example.android.fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
}
WHAT I MADE
Sub Button1_Click
Dim DIRECTORY_PICTURES As String = NativeMe.RunMethod("DIRECTORY_PICTURES", Null) 'GET PICTURE DIRECTORY LIKE SHOW ON GOOGLE API DOCUMENTATION
Dim getExternalFilesDir As String = NativeMe.RunMethod("getExternalFilesDir", Array(Null)) 'GET EXTERNAL FILES DIRECTORY LIKE SHOW ON GOOGLE API DOCUMENTATION
File.MakeDir(getExternalFilesDir,DIRECTORY_PICTURES) 'MAKE A THIS PICTURES IF NOT EXIST
fp = File.Combine(getExternalFilesDir,DIRECTORY_PICTURES) 'COMBINE THE DIR WITH DEFAULT PICTURE FOLDER NAME
'RESULTS
Log("Folder: "& fp)
Log("FileName: "& GetFileName)
imagefile = GetFileName
Dim i As Intent
i.Initialize("android.media.action.IMAGE_CAPTURE", "")
i.PutExtra("output", ParseUri("file://" & File.Combine(fp,GetFileName))) 'OPEN THE INTENT WITH THE CORRECT FOLDER AND CORRECT FILE NAME
StartActivityForResult(i)
End Sub
I get the getExternalFilesDir and the DIRECTORY_PICTURES like google code, later i combine with filename.
before start the StartActivityForResult(i) i put a output with the folder and filename.
All ok.
The problem now its this sub.
'GET FULL SIZE IMAGE
Sub ion_Event (MethodName As String, Args() As Object) As Object
If Args(0) = -1 Then '= RESULT_OK
Dim i As Intent = Args(1)
Log(i.ExtrasToString)
If File.Exists(fp,imagefile) Then
Log("Image Saved") 'HERE IS THE IMAGE
ImageView1.Bitmap = LoadBitmapSample(fp,imagefile,ImageView1.Width,ImageView1.Height) 'IMAGE IS LOADED ON IMAGEVIEW
End If
End If
Return Null
End Sub
The image its saved ok, but the log of i.ExtrasToString is = not initialized
Question 1 = How can i get the image result path, where this is stored?
on the google code this use "startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);" but here on b4a i dont know call this args.
Question 2 = how can i get the full size image with correct orientation?
with the thumb i found the fix here
https://www.b4x.com/android/forum/threads/native-camera-intents-help.69183/#post-438964
but i dont know with the full size picture
Question 3 = On google example this use a temp file, and with the intent the temp file is transformed into a image file, how can i make like google example here on b4a? how create a image temp file and use this on intent?
Question 4 = Can i get the bitmap on intent? get the bitmap on ion_Event like thumbnail example? (not only the path and filename)
Question 5 = On google example this use "com.example.android.fileprovider", what is this and how can i use here in b4a on this intent?
Question 6 = Like the question 1, how can i know if the picture is saved with sucess?
in some devices the output extra its ignored and the camera save the image with default name and dir like this
/mnt/sdcard/DCIM/Camera/2012-11-02 13.58.38.jpg
how can i check if the camera intent as ignored my output extra? and if this is ignore how can i get the default folder and file name saved?
this is a common problem in forum (ez camera have this problem of default name) and intent examples have same error.
the pictures are saved, the unique problem its know where and how get this.
would appreciate if someone with superior knowledge help, this will help not only me, have a lot of questions about native camera on the forum with no solution.
Attached I am sending two examples
Avtivity 1 = Open native camera and get the thumbnail with correct orientation and put it into a imageview
Avtivity 2 = Open native camera and get the full size picture with problem of orientation and no args on result
thx again.