3
votes

I've problem with onActivityResult only on KitKat devices , when user selected image or any file the application get force closed,I checked Crashes & ANRS from google developer console and i found this Error

STACK TRACES 1.1:Application version Android version 4.3 Y530 (hwY530-U00) Device java.lang.RuntimeException: Unable to resume activity {packageName.New_Post}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2803, result=-1, data=Intent { dat=content://media/external/images/media/3528 flg=0x1 }} to activity {packageName.New_Post}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3012) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3041) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393) at android.app.ActivityThread.access$900(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5457) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2803, result=-1, data=Intent { dat=content://media/external/images/media/3528 flg=0x1 }} to activity {packageName.New_Post}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:3614) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2999) ... 12 more Caused by: java.lang.NullPointerException at packageName.New_Post.onActivityResult(New_Post.java:343) at android.app.Activity.dispatchActivityResult(Activity.java:5442) at android.app.ActivityThread.deliverResults(ActivityThread.java:3610)

and this is the code :

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

  //if Sent from Attachment File Send information Back to It
  if ( requestCode == Api.UPLOAD_ATTACHMENT )
  {
      if (resultCode == RESULT_OK)
       {
           Uri uri         = data.getData();

           ContentValues info = new ContentValues();

           info.put("posthash", posthash);
           info.put("poststarttime", poststarttime);
           info.put("t", ShowThread.thread.threadid);
           info.put("p", p);
           info.put("editpost", 0);
           info.put("f", ShowThread.thread.forumid);
           info.put("perm", ( attcperm != null ) ? attcperm.toString() : "");

           new Attachment_upload( context  , uri , info ,attachments_box);  
       }

  }
}

i don't understand I've resultCode == RESULT_OK so if the application has not return the attachment file so why results is OK ?

1

1 Answers

0
votes

Your URI is incorrect please try to get absolute path