0

私はギャラリーで「BIG SIZE image and capture image high quality」を選択しています。強制終了エラーは次のコードとエラーも参照してください...ありがとう

コード:

 public void onActivityResult(int requestCode, int resultCode, Intent data) {
            selectedImageUri = data.getData();
            if (resultCode == RESULT_OK) {
            //  selectedImageUri = data.getData();
                if (requestCode == SELECT_PICTURE) {

    //              selectedImageUri = data.getData();
                    selectedImagePath = getPath(selectedImageUri);
                    user_img.setImageURI(selectedImageUri);

                    Log.e("select image from gallary ", "" + selectedImagePath);

                } else if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {

                    //Uri camrerauri = data.getData();
                    selectedImagePath = getPath(selectedImageUri);
                    user_img.setImageURI(selectedImageUri);
                    Log.e("capture image ", "" + selectedImagePath);

                }
            }
        }

        public String getPath(Uri uri) {
            String[] projection = { MediaStore.Images.Media.DATA };
            Cursor cursor = managedQuery(uri, projection, null, null, null);
            int column_index = cursor
                    .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        }


        public static int calculateInSampleSize(BitmapFactory.Options options,
                int reqWidth, int reqHeight) {
            // Raw height and width of image
            final int height = options.outHeight;
            final int width = options.outWidth;
            int inSampleSize = 1;

            if (height > reqHeight || width > reqWidth) {
                if (width > height) {
                    inSampleSize = Math.round((float) height / (float) reqHeight);
                } else {
                    inSampleSize = Math.round((float) width / (float) reqWidth);
                }
            }
            return inSampleSize;
        }

        public static Bitmap decodeSampledBitmapFromResource(int reqWidth,
                int reqHeight) throws IOException {
            int inSample = 8;


            // First decode with inJustDecodeBounds=true to check dimensions
            final BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            options.inSampleSize=inSample;
            // BitmapFactory.decodeResource(res, resId, options);
            //BitmapFactory.decodeStream(selectedImageUri.openConnection().getInputStream(), null,options);
            BitmapFactory.decodeFile(selectedImagePath, options);

            // Calculate inSampleSize
            options.inSampleSize = calculateInSampleSize(options, reqWidth,
                    reqHeight);

            // Decode bitmap with inSampleSize set
            options.inJustDecodeBounds = false;
            return BitmapFactory.decodeFile(selectedImagePath, options);
            //return BitmapFactory.decodeStream(new FlushedInputStream(selectedImageUri.openConnection().getInputStream()), null, options);
        }

        public static class FlushedInputStream extends FilterInputStream {
            public FlushedInputStream(InputStream inputStream) {
                super(inputStream);
            }

            @Override
            public long skip(long n) throws IOException {
                long totalBytesSkipped = 0L;
                while (totalBytesSkipped < n) {
                    long bytesSkipped = in.skip(n - totalBytesSkipped);
                    if (bytesSkipped == 0L) {
                        int b = read();
                        if (b < 0) {
                            break; // we reached EOF
                        } else {
                            bytesSkipped = 1; // we read one byte
                        }
                    }
                    totalBytesSkipped += bytesSkipped;
                }
                return totalBytesSkipped;
            }
        }

エラー:

 11-16 13:03:56.269: E/CursorWindow(11344): need to grow: mSize = 1048576, size = 1306040, freeSpace() = 1048426, numRows = 1
    11-16 13:03:56.269: E/CursorWindow(11344): Attempting to grow window beyond max size (1048576)
    11-16 13:03:56.269: E/Cursor(11344): Failed allocating 1306040 bytes for blob at 0,5
    11-16 13:03:56.279: E/CursorWindow(11344): Bad request for field slot 0,1. numRows = 0, numColumns = 6
    11-16 13:03:56.279: W/dalvikvm(11344): threadid=1: thread exiting with uncaught exception (group=0x40018560)
    11-16 13:03:56.279: E/AndroidRuntime(11344): FATAL EXCEPTION: main
    11-16 13:03:56.279: E/AndroidRuntime(11344): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rememberme/com.rememberme.BumpTest}: java.lang.IllegalStateException: get field slot from row 0 col 1 failed
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.os.Handler.dispatchMessage(Handler.java:99)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.os.Looper.loop(Looper.java:123)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.app.ActivityThread.main(ActivityThread.java:3729)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at java.lang.reflect.Method.invokeNative(Native Method)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at java.lang.reflect.Method.invoke(Method.java:507)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at dalvik.system.NativeStart.main(Native Method)
    11-16 13:03:56.279: E/AndroidRuntime(11344): Caused by: java.lang.IllegalStateException: get field slot from row 0 col 1 failed
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.database.CursorWindow.getString_native(Native Method)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.database.CursorWindow.getString(CursorWindow.java:329)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at com.rememberme.BumpTest.onCreate(BumpTest.java:279)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
    11-16 13:03:56.279: E/AndroidRuntime(11344):    ... 11 more
4

1 に答える 1