android intents
<p>I am working on android. I tried the following code but the application is not working and showing error dialog as <strong>application closed unexpectedly</strong>. It is showing error message as runtime error caused by java.lang.NullPointer exception.</p>

<p>I am including my code and manifest files here..</p>

<p><strong>IntentsActivity.java</strong></p>

<pre><code>public class IntentsActivity extends Activity {
int request_code=1;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


Button b=(Button)findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            startActivityForResult(new Intent(IntentsActivity.this,AnotherActivity.class),request_code);
        }
    });
}
public void onActivityResult(int requestcode, int resultcode, Intent data){
    if(requestcode==request_code)
        if(resultcode==RESULT_OK)
            Toast.makeText(getBaseContext(), "Data returned is "+data.getData().toString(), Toast.LENGTH_SHORT).show(); 
}
}
</code></pre>

<p><strong>AnotherActivity.java</strong></p>

<pre><code>public class AnotherActivity extends Activity{
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.anotherxml);



    Button btn=(Button)findViewById(R.id.button1);
    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            EditText edittext=(EditText)findViewById(R.id.editText1);

            Intent i=new Intent();
            i.setData(Uri.parse(edittext.getText().toString()));
            setResult(RESULT_OK,i);
            finish();
        }
    });
}
}
</code></pre>

<p><strong>Manifestfile</strong></p>

<pre><code>       &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="android.intent"
      android:versionCode="1"
      android:versionName="1.0"&gt;
    &lt;uses-sdk android:minSdkVersion="8" /&gt;

    &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
        &lt;activity android:name=".IntentsActivity"
                  android:label="@string/app_name"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
           &lt;activity android:name=".AnotherActivity"
                  android:label="@string/app_name"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.AnotherActivity" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
    &lt;/manifest&gt;
</code></pre>

<p>Here main.xml file consists a button and another.xml consists consists a EditText and a button. Can anyone give me the reason why the application is not working</p>
