开发者

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.

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜