//this is inatance variable variabale to get the image from camera
ActivityResultLauncher<Intent> secondActivityResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getResultCode() == Activity.RESULT_OK) {
Intent data = result.getData();
bitmapImageCamera= (Bitmap) data.getExtras().get("data");
ImageView imageView=mView.findViewById(R.id.bikeimage);
imageView.setVisibility(View.VISIBLE);
// imageView.setImageURI(data.getData());
imageView.setImageBitmap(bitmapImageCamera);
Toast.makeText(RequestActivity.this, "image set sucess full", Toast.LENGTH_LONG).show();
}else
{
Toast.makeText(RequestActivity.this, "image not get from ", Toast.LENGTH_LONG).show();
}
}
);
//call this function by clicking any button
private void openCameraLogic() {
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(intent.resolveActivity(getPackageManager())!=null)
{
secondActivityResultLauncher.launch(intent);
}
}
No comments:
Post a Comment