I'm trying to use my android camera in an app so that when I take the first photo I'm not redirected to the home screen.
The app is currently as follows:
Clicking on "Take Calibration Photos" is directed to the camera where when taking the photo is asked if I want to save the photo or repeat the process.
Myquestionis:Howtocapturemultipleimagesatoncewithouthavingtogobacktothehomescreenandclick"Take photos calibration" again.
The following is the application code:
public class MainActivity extends AppCompatActivity {
ImageView imageView; // campo onde sera exibido a foto
Button btnCameraCalibrate;
private File arquivo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView) findViewById(R.id.imageView);
btnCameraCalibrate = (Button) findViewById(R.id.btnPicturesCalibration);
btnCameraCalibrate.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//cria pasta para guardar fotos
File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM+"/Reccoon3D");
if(!pictureDirectory.exists()){
pictureDirectory.mkdirs();
}
//nomeia a foto baseada em data e hora
String pictureName = getCalibrationPictureName();
File imagemCalib = new File(pictureDirectory,pictureName);
Uri pictureUri = Uri.fromFile(imagemCalib);
intent.putExtra(MediaStore.EXTRA_OUTPUT,pictureUri);
startActivityForResult(intent,0);
}
});
}
private String getCalibrationPictureName() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String timestamp = sdf.format(new Date());
return "Calibration"+timestamp+".jpg";
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode,resultCode,data);
//Bitmap bitmap = (Bitmap)data.getExtras().get("data");
//imageView.setImageBitmap(bitmap);
}
}