简体   繁体   English

7英寸平板电脑在我的人像视图中的Imageview中未显示相机捕获图像

[英]Camera capture image not showing in Imageview in my portrait view for 7 inch tablet

I want to show image Capture through camera in image View in My 7 inch tablet 3.2. 我想在我的7英寸平板电脑3.2的图像视图中显示通过相机捕获的图像。 When i am capturing image and control returns to my activity image not displaying in Image View . 当我捕获图像并且控件返回到我的活动图像时,该图像未显示在“ Image View But same thing working properly on Smartphones. 但是同样的事情在智能手机上也能正常工作。

I also tried with android:configChanges="keyboardHidden|orientation" in manifest for that activity but still problem exist. 我也尝试在清单中使用android:configChanges="keyboardHidden|orientation"进行该活动,但仍然存在问题。

If i am capturing Image by keeping tablet in landscape it working fine and displaying image. 如果我通过将平板电脑保持在横向模式来捕获图像,则它可以正常工作并显示图像。

I call Camera intent as below 我将相机意图称为如下

I am running my app on 7 inch Samsung tablet GT-P6200 of version 3.2 . 我在7英寸3.2三星平板电脑GT-P6200上运行我的应用程序。

Camera Intent I called as below 我打电话给我的相机意图如下

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

Please help me out of this issue 请帮我解决这个问题

My activity Result method 我的活动结果方法

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == PICTURE_FROM_CAMERA) {
            Bitmap bitmap = (Bitmap) data.getExtras().get("data");
            photoView.setImageBitmap(bitmap);
        }
    }
}

尝试将设备旋转到横向,因为MediaStore捕获仅在横向模式下有效。

This is a Common issue in Some tab, for this issue you may try this following code. 这是“某些”选项卡中的一个常见问题,对于此问题,您可以尝试下面的代码。 it works for me. 这个对我有用。

 try {
        File f = new File(SD_CARD_IMAGE_PATH);
        ExifInterface exif = new ExifInterface(f.getPath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

        int angle = 0;

        if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
            angle = 90;
        } 
        else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
            angle = 180;
        } 
        else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
            angle = 270;
        }

        Matrix mat = new Matrix();
        mat.postRotate(angle);

        Bitmap bmp = BitmapFactory.decodeStream(new FileInputStream(f), null, null);
        Bitmap correctBmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), mat, true);                 
    }
    catch (IOException e) {
        Log.w("TAG", "-- Error in setting image");
    }   
    catch(OutOfMemoryError oom) {
        Log.w("TAG", "-- OOM Error in setting image");
    }

But should I use in else form? 但是我应该以其他形式使用吗?

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

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