开发者

How to Capture Image in Android?

开发者 https://www.devze.com 2023-04-04 11:05 出处:网络
I use the following code to capture the image. Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

I use the following code to capture the image.

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,outputFileUri);
startActivityForResult(cameraIntent,CAPT_PHOTO);

It work's fine for the HTC Legend,HTC desire,Samsung galaxy and Samsung galaxy tab.

But in LG optimus opens the camera and save the image file by it's own name and uri. Ho开发者_如何学编程w to solve this?


You can try to add an extra Extra: MediaStore.EXTRA_MEDIA_TITLE where you can define the title of the image. Hope this helps!


   choosePhotoImage = Environment.getExternalStorageDirectory()+ "/make_machine_example" + (counter++) + ".jpg";
                        File file = new File(choosePhotoImage);
                        Uri outputFileUri = Uri.fromFile(file);

                        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,outputFileUri);
                        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
0

精彩评论

暂无评论...
验证码 换一张
取 消