I'm using this code to open camera intent :
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePicture.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
startActivityForResult(takePicture, 0);
And it works fine but only on Samsung devices (8\9) with android 8
after I take a picture the preview is all blurry ,
anyone got that weird behavior ?
( I also tried without the putExtra line )
Here are the screenshots :
]3
you have to give a photo path Uri as an extra in the camera intent as:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), mUserID + ".jpg");
Uri photoPath = getUriForFile(mContext, BuildConfig.APPLICATION_ID, file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoPath); //--> here
startActivityForResult(Intent.createChooser(intent, "Complete action using"), REQUEST_CODE_CAMERA);
then, you can get the captured image in that Uri itself in onActivityResult
Related
I tried other questions' methods, but for me, these methods do not work .
I want to use intent to start front camera. I try to do it
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extras.CAMERA_FACING",1);
mFile = Utils.getVisitorImage();
Uri imageUri = FileProvider.getUriForFile(
getActivity(),
getActivity().getPackageName() + ".fileprovider",
mFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAMERA_PHOTO_REQUEST_CODE);
but,it does't work. my device is Android 7.1.1 or some device higher 6.0.1.
How to use intent start front camera? I hope someone help me.Thanks.
I am working on application where I am recording video from Camera Intent. On my Samsung mobile MediaStore.EXTRA_VIDEO_QUALITY is working and even my allocated memory size also works but same application on my Google Pixel there MediaStore.EXTRA_VIDEO_QUALITY is not working and even allocated size of memory is not working with camera intent.
My code is given below:
public void takeVideoFromCamera(){
File mediaFile =new File(Environment.getExternalStorageDirectory().getAbsolutePath()+ "/myvideo.mp4");
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
Uri videoUri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// videoUri = FileProvider.getUriForFile(this, this.getApplicationContext().getPackageName() + ".provider", mediaFile);
videoUri = FileProvider.getUriForFile(this, "i.am.ce.by.murgqcy.provider", mediaFile);
} else {
videoUri = Uri.fromFile(mediaFile);
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 5491520L);//5*1048*1048=5MB
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,45);
startActivityForResult(intent, VIDEO_CAPTURE);
}
According to MediaStore.EXTRA_VIDEO_QUALITY
You should change the value of MediaStore.EXTRA_VIDEO_QUALITY from 0 to 1.
0 means low quality
Thus could be the solution intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
I have Android Xamarin application with imageview
OnClik I lunch intent to preview image
File file = new File(photoPath);
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(Uri.FromFile(file), "image/*");
intent.SetFlags(ActivityFlags.NoHistory);
StartActivity(intent);
from apps I choose 'Gallery'
when the image is opend there are no sharing options
when I open image from device 'Gallery' has sharing options
Image is saved to SD card before preview.
what am I doing wrong ?
solution that worked for me
Intent intent = new Intent();
intent.PutExtra(Intent.ActionView, photoPath);
intent.SetType("image/*");
StartActivity(Intent.CreateChooser(intent, "Select Picture"));
now I get my image opend in gallery and I can use sharing options too
Do it using Intent.ACTION_SEND and you'll get that sharing option.
Also try with Intent.ACTION_GET_CONTENT.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), 1);
I have a weird problem!
My application calls the phone's camera to take a picture.
The photo is taken and stored in the ad hoc directory successfully
However, when I open the photo is not displayed (black screen)
and when I send the photo by email I can open it in my pc.
Here is the code :
String imageName = txtNomPhoto.getText().toString()+JPEG_FILE_SUFFIX;
File dossier = new File(Environment.getExternalStorageDirectory(),"/DossierPhotos");
if (!dossier.exists()){
if (dossier.mkdir()){
}
}
File mFichier = new File(dossier.getAbsolutePath(),imageName);
Uri fileUri = Uri.fromFile(mFichier);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(intent, PHOTO_RESULT);
Thank you for your quick help.
I got this working with Images like:
Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setType("image/*");
image = new File(projectPathFull,"testapp_"+imageCounter+".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
startActivityForResult(intent, REQUEST_PICK_IMAGE);
This creates the picked image in my folder testapp
But it doesnt work with Audiofiles somehow.
This is my code:
Intent toAudioSelect = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
audio = new File(projectPathFull,"testapp_"+imageCounter+".mp3");
toAudioSelect.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(audio));
startActivityForResult(toAudioSelect, REQUEST_PICK_AUDIO);
Any Ideas?