我正试图在从图库加载时缩小图像,但我收到此错误。
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);
}