@adaptinnovative ===
I have written the code initially put; i have tested it again (OS6 MM), with some little modifs and it works: i can see the folder “camerademo” inside PICTURES and i can see the photo inside it. It is possible that URIfromFile does not work for OS>6 MM, yet you can try and it s esay to change this part of the code. Dont forget to ask permissions on rutime if you using a phone more than lollypop.
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.os.Environment;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
int MyVersion = Build.VERSION.SDK_INT;
Intent intent;
Uri file;
public static final int CAMERA_REQUEST = 1;
Activity act;
boolean accordees = false;
public void setup(){
orientation(LANDSCAPE);
size(displayWidth, displayHeight);
act = this.getActivity();
///here ask for permissions: CAMERA, WRITE_EXTERNALSTORAGE on rutime, not only through the Manifest
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Uri file = Uri.fromFile(getOutputMediaFile());
println(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, file);
act.startActivityForResult(intent,CAMERA_REQUEST );
};
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult( requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK){
println("camera ok);
}
};
public void draw(){
}
private static File getOutputMediaFile(){
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), "CameraDemo");
if (!mediaStorageDir.exists()){
if (!mediaStorageDir.mkdirs()){
return null;
}
}
return new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ System.currentTimeMillis() + ".jpg");
};