Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android createScaledBitmap引发空指针异常_Android_Nullpointerexception_Android Bitmap - Fatal编程技术网

Android createScaledBitmap引发空指针异常

Android createScaledBitmap引发空指针异常,android,nullpointerexception,android-bitmap,Android,Nullpointerexception,Android Bitmap,当从gallery加载图像时,我试图缩小图像的比例,但出现了此错误 08-29 18:22:12.412 32203-32203/com.almaarijsoft.kanvas W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x417c3da0) 08-29 18:22:12.412 32203-32203/com.almaarijsoft.kanvas E/AndroidRuntime﹕ FATA

当从gallery加载图像时,我试图缩小图像的比例,但出现了此错误

08-29 18:22:12.412  32203-32203/com.almaarijsoft.kanvas W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x417c3da0)
08-29 18:22:12.412  32203-32203/com.almaarijsoft.kanvas E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.almaarijsoft.kanvas, PID: 32203
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/1412 (has extras) }} to activity {com.almaarijsoft.kanvas/com.almaarijsoft.kanvas.Activities.ProfileActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3663)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3706)
            at android.app.ActivityThread.access$1400(ActivityThread.java:173)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5579)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.almaarijsoft.kanvas.Activities.ProfileActivity.onActivityResult(ProfileActivity.java:136)
            at android.app.Activity.dispatchActivityResult(Activity.java:5643)
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3659)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3706)
            at android.app.ActivityThread.access$1400(ActivityThread.java:173)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5579)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
            at dalvik.system.NativeStart.main(Native Method)
这是我的密码

                    BitmapDrawable bmpDrawable = null;
                    // try to retrieve the image using the data from the intent
                    Cursor cursor = getContentResolver().query(data.getData(),
                            null, null, null, null);
                    if (cursor != null) {

                        cursor.moveToFirst();

                        int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
                        String fileSrc = cursor.getString(idx);
                        bitmap = BitmapFactory.decodeFile(fileSrc); // load
                        bitmap = Bitmap.createScaledBitmap(bitmap,
                                100, 100, false);// this is line 136
                        img_logo.setImageBitmap(bitmap);
                    } else {

                        bmpDrawable = new BitmapDrawable(getResources(), data
                                .getData().getPath());
                        img_logo.setImageDrawable(bmpDrawable);
                    }

你能指出你的“活动简介”的第136行吗?你能指出你的“活动简介”的第136行吗?