简体   繁体   English

如何在Android中捕获图像?

[英]How to Capture Image in Android?

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. 对于HTC Legend,HTC欲望,三星银河和三星银河选项卡来说,它工作正常。
But in LG optimus opens the camera and save the image file by it's own name and uri. 但是在LG中,Optimus打开相机并通过其自己的名称和uri保存图像文件。 How to solve this? 如何解决呢?

You can try to add an extra Extra: MediaStore.EXTRA_MEDIA_TITLE where you can define the title of the image. 您可以尝试添加额外的Extra: MediaStore.EXTRA_MEDIA_TITLE ,您可以在其中定义图像的标题。 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM