title: intent startActivityForResult returned result but the program crashed
body: <p>ok the parent activity call BuyActivity using startActivityForResult and return 3 values to the parent activity. One of them is category. There are 3 categories food, personal and education that can be chose. I got no problem when i choose education or personal but i get this error when i choose food but the parent activity still received all the 3 values returned. So anyone can help? </p>
  
  <pre><code>java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {apps.project/apps.project.ConsultExpert}: java.lang.NullPointerException 
  </code></pre>
  
  <p>this function call the startActivityForResult</p>
  
  <pre><code> private void displayBuyQuestionnaire() {
      Intent intent = new Intent(this, BuyActivity.class);
      startActivityForResult(intent, BUY_ADVICE); 
  }
  </code></pre>
  
  <p>inside BuyActivity.class</p>
  
  <pre><code>Intent returnIntent = new Intent();
              returnIntent.putExtra("item_name", iName);
              returnIntent.putExtra("item_price", iPrice);
              returnIntent.putExtra("item_category", iCategory);
              setResult(RESULT_OK,returnIntent); 
              finish();
  </code></pre>
  
  <p>onActivityResult</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      switch(requestCode) {
      case BUDGET_ADVICE: 
          if (resultCode == RESULT_OK &amp;&amp; data.hasExtra("status")) {
              item_name = data.getStringExtra("status");
              Log.d("return", data.getStringExtra("status"));
              runBudgetTree();
          }
          else {
              if(resultCode == RESULT_OK)
                  Log.d("msg", "result code ok tp x semua return");
          }
              break;
  
      case BUY_ADVICE:
          if (resultCode == RESULT_OK) {
             item_name = data.getStringExtra("item_name");           
             item_category = data.getStringExtra("item_category");
             item_price = data.getDoubleExtra("item_price", 0);
             runBuyTree();
          }
  
          break;
      }
  </code></pre>
  
  <p>LogCat</p>
  
  <blockquote>
    <p>01-09 17:56:51.776: D/var i(3159): answer1 01-09 17:56:51.776: D/var
    i(3159): answer2 01-09 17:56:51.776: D/var i(3159): answer3 01-09
    17:56:51.781: D/AndroidRuntime(3159): Shutting down VM 01-09
    17:56:51.781: W/dalvikvm(3159): threadid=1: thread exiting with
    uncaught exception (group=0x4001e578) 01-09 17:56:51.786:
    E/AndroidRuntime(3159): FATAL EXCEPTION: main 01-09 17:56:51.786:
    E/AndroidRuntime(3159): java.lang.RuntimeException: Failure delivering
    result ResultInfo{who=null, request=1, result=-1, data=Intent { (has
    extras) }} to activity {apps.project/apps.project.ConsultExpert}:
    java.lang.NullPointerException 01-09 17:56:51.786:
    E/AndroidRuntime(3159):   at
    android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
    01-09 17:56:51.786: E/AndroidRuntime(3159):   at
    android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
    01-09 17:56:51.786: E/AndroidRuntime(3159):   at
    android.app.ActivityThread.access$2000(ActivityThread.java:117) 01-09
    17:56:51.786: E/AndroidRuntime(3159):     at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
    01-09 17:56:51.786: E/AndroidRuntime(3159):   at
    android.os.Handler.dispatchMessage(Handler.java:99) 01-09
    17:56:51.786: E/AndroidRuntime(3159):     at
    android.os.Looper.loop(Looper.java:130) 01-09 17:56:51.786:
    E/AndroidRuntime(3159):   at
    android.app.ActivityThread.main(ActivityThread.java:3691) 01-09
    17:56:51.786: E/AndroidRuntime(3159):     at
    java.lang.reflect.Method.invokeNative(Native Method) 01-09
    17:56:51.786: E/AndroidRuntime(3159):     at
    java.lang.reflect.Method.invoke(Method.java:507) 01-09 17:56:51.786:
    E/AndroidRuntime(3159):   at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
    01-09 17:56:51.786: E/AndroidRuntime(3159):   at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 01-09
    17:56:51.786: E/AndroidRuntime(3159):     at
    dalvik.system.NativeStart.main(Native Method) 01-09 17:56:51.786:
    E/AndroidRuntime(3159): Caused by: java.lang.NullPointerException
    01-09 17:56:51.786: E/AndroidRuntime(3159):   at
    apps.project.ConsultExpert.runBuyTree(ConsultExpert.java:364) 01-09
    17:56:51.786: E/AndroidRuntime(3159):     at
    apps.project.ConsultExpert.onActivityResult(ConsultExpert.java:1769)
    01-09 17:56:51.786: E/AndroidRuntime(3159):   at
    android.app.Activity.dispatchActivityResult(Activity.java:3934) 01-09
    17:56:51.786: E/AndroidRuntime(3159):     at
    android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
    01-09 17:56:51.786: E/AndroidRuntime(3159):   ... 11 more</p>
  </blockquote>