0

QuizActivity starts MainActivityV3 with startActivityForResult() , and passes an ArrayList in a Bundle.

The ArrayList contains objects of type 'Frage'. MainActivityV3 modifies some objects of the ArrayList and passes this back to QuizActivity.

Here is a clipping of the code:

Frage.java

<pre>
    import java.io.Serializable;
    public class Frage implements Serializable {
       static final long serialVersionUID = 242526L;
       String frage;
       String antworta;
       String antwortb;
       String antwortc;
       String antwortd;
       int loesung;
    //following getter- and setter-Methods
       .
       .
    }

    //*** QuizActivity.java
      public Frage[] fragen;
      //array is filled with objects of type Frage
      .
      .
      void startInt() {
        Intent intent=new Intent(this,MainActivityV3.class);
        Bundle b = new Bundle();
        ArrayList mal=new ArrayList();
        for (Frage fr: fragen) {
            mal.add(fr); //Frage-Objects -> ArrayList
        }
        b.putSerializable("key", mal);
        intent.putExtras(b);
        startActivityForResult(intent,1);
      }
      .
      .
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
       //the parameter are 1,0 and null
        if (resultCode == Activity.RESULT_OK) {
          Bundle daten = data.getExtras();
          frList=(ArrayList)daten.getSerializable("key");
          int i=0;
          for (Frage f: frList) {
              fragen[i++]=f;
          }
        }
      } 
</pre>    


**MainActivityV3.java**

<pre>

    //modifying data of ArrayList, passing this back
    @Override
    public void onBackPressed() {
    Bundle b = new Bundle();
    Intent result=new Intent();
    //mal: the ArrayList, Debugger shows correctly the data
    b.putSerializable("key", mal); 
    result.putExtras(b);
    this.setResult(Activity.RESULT_OK,result);
    finish();
    }

</pre>

My problem: the 3 parameters in onActivityResult() are 1,0,null. Why is the Intent parameter null? Please help me.

user3589211
  • 89
  • 2
  • 13

0 Answers0