How to auto ok when use camera of android? - android

I have a problem, it is i using camera of android with call MediaStore.ACTION_IMAGE_CAPTURE
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
filepath = getOutputMediaFile();
uri = Uri.fromFile(filepath);
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(cameraIntent, 0);
When i capture and then it don't auto save, i must be click to buttom save or buttom not, while i just need to save.
Button save and button not
This not comfortable, so how to set auto save and pretermit this step?

That's a function of the camera app. You would have to wrote your own code for capturing an image with the camera.

Related

ACTION_IMAGE_CAPTURE on samsung device blurred

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

my image is not displayed

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.

Front-face in Android camera by default

I am using this code:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File("/sdcard/picture.png");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
Uri imageUri = Uri.fromFile(photo);
startActivity(intent);
I would like to use this intent with a pre-defined setting, like front facing by default every time I fire the camera. Is that possible?
This is the front Camera intent, use it in your code!
here is an good tutorial: http://www.vogella.com/articles/AndroidCamera/article.html
int CAMERA_FACING_FRONT
Read more here: http://developer.android.com/reference/android/hardware/Camera.html

Android Camera for Picture and Video

I want to start camera activity in my android app and I know how to do that. I want to ask when the camera activity finishes, how can I check as if it was the picture or the video taken by the user?
UPDATED
I have a dialog where it asks 2 things.
New Photo or Video
Existing Photo or Video
If it's no. 1, it means camera will be started and user can either take a picture or the video and it will return to the activity.
If it's no.2, it mean gallery will be started having pictures and videos for a user to select one and will return back to the activity.
Hello Umair,
I have done this type of application I searched many time but I didn't get any proper solution so I changed your my menu & they are now
1)Take New Photo
2)Take New Video
3)Existing Image/Video
Process will be like this
1)I use an global variable
2)So when user click on menu one I sets global variable value to 1
3) Start the activity for result like below
try{
System.gc();
String fileName = System.currentTimeMillis()+".jpg";
String mPathImage = Environment.getExternalStorageDirectory()+ "/" + fileName;
File file = new File(mPathImage);
Uri outputFileUri = Uri.fromFile( file );
Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
mIntent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult(mIntent, 1);
mValue=1;
}catch(Exception e){
}
If User click on menu 2 I change value of global variable to 2
& starts the activity for result like below.
try {
System.gc();
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, 1);
mValue=2;
}catch(Exception e){}
If user click on 3rd menu I set value to 3
& start the activity for result like below.
try{
System.gc();
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(intent,1);
mValue=3;
}catch(Exception e){}
}
This will show all the images & video's in mobile
Then finally when activity gets closed use global variable to check whether user want to new image or video or existing image/video.
Hope this will help you..

Jpeg compression quality in android

I am launching the image capture intent to take a picture, adding a uri so the picture is tiny. My problem is I want to set the output jpeg-quality before I start the activity.
ContentValues vals = new ContentValues();
vals.put(Media.DISPLAY_NAME, "test title");
vals.put(Media.MIME_TYPE, "image/jpeg");
Uri imageFileUri = context.getContentResolver()
.insert(Media.EXTERNAL_CONTENT_URI, vals);
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
context.startActivityForResult(i, CameraImportActivity.CAMERA_REQUEST);
I suppose I could downsample after the picture is taken, but if I can request the activity do it for me I would like to do so.
As bonus questions, how do I change the album they get saved to in the gallery, and how do I prevent the camera activity from saving a copy in the default location (on my phone it is "photos")

Categories

Resources