NullPointerException in caller activity, I think
<p>My basic aim is to launch an activity from within another, and have
the result of the second activity be returned to the first. Problem
is, the second one keeps crashing. LogCat reveals that there was a
NullPointerException at the first after the second activity was
finished. Do I have to apply certain intent filters to it, or put some
other attribute in the manifest? Am using the onActivityResult method
in the first activity, and just and using</p>

<p>setResult(RESULT_OK, new Intent().setAction(sLat + ',' + sLon))</p>

<p>in the second activity, where sLat and sLon are strings.</p>

<p>Help would be appreciated. Thanks.</p>

<p>Here's the code for the two files.</p>

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

private EditText title;
private EditText notes;
private TextView mResult;
static final private int GET_CODE=0;

@Override 
public void onCreate(Bundle icicle){
    super.onCreate(icicle);
    setContentView(R.layout.insert);
    notes=(EditText)findViewById(R.id.EditText02);

    mResult=(TextView)findViewById(R.layout.insert);

    Button locButton=(Button)findViewById(R.id.Button02);
    locButton.setOnClickListener(locGetListener);

}

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

    if (requestCode == GET_CODE){
        Editable text=(Editable)mResult;

        if(resultCode==RESULT_CANCELED){
            text.append("Cancelled");
        }else{
            if(data!=null){
                text.append(data.getAction());
            }
        }

    }


}

private OnClickListener locGetListener = new OnClickListener(){

    public void onClick(View v){
        Intent intent = new Intent(Insert.this,createNote.class);
        startActivityForResult(intent,GET_CODE);

    }

};




  }
</code></pre>

<p>and the subactivity is</p>

<pre><code>public class createNote extends MapActivity {

@Override
protected boolean isRouteDisplayed() {
    return false;
}       

@Override
public void onCreate(Bundle savedInstanceStates){       
    super.onCreate(savedInstanceStates);
    setContentView(R.layout.map);

    MapView mapview=(MapView)findViewById(R.id.MapView);
    mapview.setBuiltInZoomControls(true);

    mapOverlay mapoverlay=new mapOverlay();
    List&lt;Overlay&gt;listOfOverlays=mapview.getOverlays();
    listOfOverlays.add(mapoverlay);


}   


class mapOverlay extends com.google.android.maps.Overlay{
    @Override

    public boolean onTouchEvent(MotionEvent event, MapView mapview){
        GeoPoint p=null;

        if (event.getAction()==1){
             p=mapview.getProjection().fromPixels((int)event.getX(), (int)event.getY());
            Toast.makeText(getBaseContext(),p.getLatitudeE6()/1E6 + "," + p.getLongitudeE6()/1E6, Toast.LENGTH_SHORT).show();



        double lat=(double) (p.getLatitudeE6()/1E6);
        double lon=(double) (p.getLongitudeE6()/1E6);

        String sLat=Double.toString(lat);
        String sLon=Double.toString(lon);

        Toast.makeText(getBaseContext(),sLat + "-" + sLon,Toast.LENGTH_SHORT).show();


        setResult(RESULT_OK, new Intent().setAction(sLat + ',' + sLon));
        finish();
        }
        return false;
    }
}
</code></pre>

<p>}</p>
