cursor空指針
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
? ?if(requestCode == PICK_CODE){
? ? ? ?if(data!=null){
? ? ? ? ? ?Uri uri = data.getData();
? ? ? ? ? ?Cursor cursor = getContentResolver().query(uri,null,null,null,null);
? ? ? ? ? ?Log.e("TAG",cursor.toString());
? ? ? ? ? ?cursor.moveToFirst();
? ? ? ? ? ?int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
? ? ? ? ? ?mCurrentPhotoStr = cursor.getString(idx);
? ? ? ? ? ?cursor.close();
? ? ? ? ? ?resizePhoto();
? ? ? ? ? ?mPhoto.setImageBitmap(mPhotoImg);
? ? ? ? ? ?mTip.setText("Click Detect ==>");
? ? ? ?}
? ?}
? ?super.onActivityResult(requestCode, resultCode, data);
}
cursor ?是空指針看不錯(cuò),是哪里有問(wèn)題
2016-04-22
我的也是這問(wèn)題。。。
2015-08-28
08-28 11:32:16.730 ?20664-20664/com.imooc.imooc_how_old E/AndroidRuntime﹕ FATAL EXCEPTION: main
? ? Process: com.imooc.imooc_how_old, PID: 20664
? ? java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=272, result=-1, data=Intent { dat=file:///storage/emulated/0/DCIM/Camera/IMG_20150801_141745.jpg typ=image/jpeg }} to activity {com.imooc.imooc_how_old/com.imooc.imooc_how_old.MainActivity}: java.lang.NullPointerException
? ? ? ? ? ? at android.app.ActivityThread.deliverResults(ActivityThread.java:3356)
? ? ? ? ? ? at android.app.ActivityThread.handleSendResult(ActivityThread.java:3399)
? ? ? ? ? ? at android.app.ActivityThread.access$1300(ActivityThread.java:138)
? ? ? ? ? ? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1249)
? ? ? ? ? ? at android.os.Handler.dispatchMessage(Handler.java:102)
? ? ? ? ? ? at android.os.Looper.loop(Looper.java:136)
? ? ? ? ? ? at android.app.ActivityThread.main(ActivityThread.java:5016)
? ? ? ? ? ? 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:792)
? ? ? ? ? ? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
? ? ? ? ? ? at dalvik.system.NativeStart.main(Native Method)
? ? ?Caused by: java.lang.NullPointerException
? ? ? ? ? ? at com.imooc.imooc_how_old.MainActivity.onActivityResult(MainActivity.java:65)
? ? ? ? ? ? at android.app.Activity.dispatchActivityResult(Activity.java:5443)
? ? ? ? ? ? at android.app.ActivityThread.deliverResults(ActivityThread.java:3352)
? ? ? ? ? ? at android.app.ActivityThread.handleSendResult(ActivityThread.java:3399)
? ? ? ? ? ? at android.app.ActivityThread.access$1300(ActivityThread.java:138)
? ? ? ? ? ? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1249)
? ? ? ? ? ? at android.os.Handler.dispatchMessage(Handler.java:102)
? ? ? ? ? ? at android.os.Looper.loop(Looper.java:136)
? ? ? ? ? ? at android.app.ActivityThread.main(ActivityThread.java:5016)
? ? ? ? ? ? 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:792)
? ? ? ? ? ? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
? ? ? ? ? ? at dalvik.system.NativeStart.main(Native Method)