从自定义构建的相机应用程序

时间:2017-03-16 18:32:33

标签: android

这是我使用的图像选择器代码:

 private void openGallery() {
    Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
    startActivityForResult(gallery, PICK_IMAGE);

}

和" onActivityResult" :

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) {

        Bitmap photo = (Bitmap) data.getExtras().get("data");
        mImageView.setImageBitmap(photo);

    } else if (resultCode == RESULT_OK && requestCode == PICK_IMAGE) {
        imageUri = data.getData();
        mImageView.setImageURI(imageUri);


        }

    }

所以任何人都可以告诉我我做错了什么

我在logcat中得到了这个:

  

03-16 23:30:00.631 12217-12217 / com.example.rafiamansoor.camapp   E / AndroidRuntime:致命异常:主要                                                                                    过程:com.example.rafiamansoor.camapp,PID:12217                                                                                    java.lang.RuntimeException:release()之后调用的方法                                                                                        在android.hardware.Camera.setPreviewSurface(Native方法)                                                                                        在android.hardware.Camera.setPreviewDisplay(Camera.java:679)                                                                                        在   com.example.rafiamansoor.camapp.CameraView.surfaceCreated(CameraView.java:46)                                                                                        在android.view.SurfaceView.updateWindow(SurfaceView.java:666)                                                                                        在   android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:299)                                                                                        在android.view.View.dispatchWindowVisibilityChanged(View.java:9370)                                                                                        在   android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1285)                                                                                        在   android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1285)                                                                                        在   android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1285)                                                                                        在   android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1285)                                                                                        在   android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1285)                                                                                        在   android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1285)                                                                                        在   android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1285)                                                                                        在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1507)                                                                                        在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1230)                                                                                        在   android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6726)                                                                                        在   android.view.Choreographer $ CallbackRecord.run(Choreographer.java:777)                                                                                        在android.view.Choreographer.doCallbacks(Choreographer.java:590)                                                                                        在android.view.Choreographer.doFrame(Choreographer.java:560)                                                                                        在   android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:763)                                                                                        在android.os.Handler.handleCallback(Handler.java:739)                                                                                        在android.os.Handler.dispatchMessage(Handler.java:95)                                                                                        在android.os.Looper.loop(Looper.java:145)                                                                                        在android.app.ActivityThread.main(ActivityThread.java:6141)                                                                                        at java.lang.reflect.Method.invoke(Native Method)                                                                                        在java.lang.reflect.Method.invoke(Method.java:372)                                                                                        在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1399)                                                                                        在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

并且肖像照片也以横向模式保存,因此任何人都可以告诉我如何修复方向

0 个答案:

没有答案