开发者

How To Take Photo from Default Camera and Use this Photo in My Application? [duplicate]

开发者 https://www.devze.com 2023-03-28 21:06 出处:网络
This question already has answers here: Closed开发者_如何学Python 11 years ago. Possible Duplicate:
This question already has answers here: Closed开发者_如何学Python 11 years ago.

Possible Duplicate:

How to capture an image and store it with the native Android Camera

How To capture Photo from Default Camera and Use this Photo in My Application? My Main Problem is I was capture Photo & use this Photo in my Application completely but if i select the photo and get in my application screen that time the Orientation is changed.

My Code is Following :-

For Start Camera:-

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

For Take Captured Image:-

Bitmap bitmap;
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if(requestCode == CAMERA_PIC_REQUEST) {
            System.out.println("Dipak Keshariya");
            bitmap = (Bitmap) data.getExtras().get("data");
            drawable = new BitmapDrawable(bitmap);
            mRlayoutimage.setVisibility(View.VISIBLE);
            mRlayoutimage.setBackgroundDrawable(drawable);
        }
    }
}


You call

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

Or

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT):

to lock the orientation change temporarily. You can change it back to ActivityInfo.SCREEN_ORIENTATION_SENSOR after you get the photo.

0

精彩评论

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