Intent problems in Android
<p>I have two Activities in my Android Application, Activity A and Activity B. Activity A triggers Activity B by an Intent and then when I'm in Activity B, which is a listView I click on a particular item and pass data back to Activity A by using putExtras() as part of my Intent when going back to Activity A. </p>

<p>The problem that I have is that when I select on an item from the listView that I want to pass back to Activity A the application crashes, but when I use a normal intent, which doesn't pass any data across Activities it works fine.</p>

<p>The code below demonstrates what I am trying to do.</p>

<p>Activity A  </p>

<pre><code>public class ActivityA extends Activity {

    private String myString;
    @Override
protected void onCreate(Bundle savedInstanceState) 
{
      Button selectEvent = (Button) findViewById(R.id.events);

      myString = savedInstanceState != null ? savedInstanceState.getString("myKey"):null;

     if(myIntentString == null)
     {
         Bundle extras = getIntent().getExtras();

         myString = extras != null ? extras.getString("myKey"):null;
     }

     selectEvent.setText(myString);

     selectEvent.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myIntent = new Intent(ActivityA.this, ActivityB.class);
                ActivityA.this.startActivity(myIntent);
            }
        });
   }
}


public class ActivityB extends ListActivity 
{
private String selection;
private final int SECONDARY_ACTIVITY_REQUEST_CODE = 0;
String[] listOfNames = {"Peter", "Paul", "John"};

/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.events);

    setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, listOfData));
}

protected void onListItemClick(ListView l, View v, int position, long id)
{
    selection = l.getItemAtPosition(position).toString();

            Intent myIntent = new Intent(getApplicationContext(), ActivityA.class);

            myIntent.putExtra("myKey", selection);

            startActivityForResult(myIntent, SECONDARY_ACTIVITY_REQUEST_CODE);
}
}
</code></pre>

<p>Your help would be most appreciated, thank you.</p>
