title: starting activity for sending mail in android
body: <p>I am designing an application for sending mail. All is set but when the code reaches to the following line in the emmulator it says "application has stopped unexpectedly" and the log cat shows NullPointerException. I have also given as many permissions i found. Plz help me with what specific permissions must be given in manifest file and how can the problem be resolved.</p>
  
  <pre><code>startActivity(Intent.createChooser(send, "This is the chooser title"));
  </code></pre>
  
  <p>Send is my intent here.</p>
  
  <p>Complete log cat msg is below:</p>
  
  <pre><code>11-01 23:21:37.721: W/IInputConnectionWrapper(442): showStatusIcon on inactive InputConnection
  11-01 23:21:39.781: I/msg(442): this is offhook
  11-01 23:21:43.991: I/msg(442): this is idle
  11-01 23:21:43.991: I/msgfinal(442): this is it
  11-01 23:21:43.991: I/msg(442): this is from msg
  11-01 23:21:43.991: I/sha(442): here
  11-01 23:21:43.991: D/AndroidRuntime(442): Shutting down VM
  11-01 23:21:43.991: W/dalvikvm(442): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  11-01 23:21:43.991: E/AndroidRuntime(442): FATAL EXCEPTION: main
  11-01 23:21:43.991: E/AndroidRuntime(442): java.lang.NullPointerException
  11-01 23:21:43.991: E/AndroidRuntime(442):  at android.app.Activity.startActivityForResult(Activity.java:2827)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at android.app.Activity.startActivity(Activity.java:2933)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at com.example.dialing.MainActivity.fun(MainActivity.java:33)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at com.example.dialing.PhoneCallListener.onCallStateChanged(MainActivity.java:104)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at android.telephony.PhoneStateListener$2.handleMessage(PhoneStateListener.java:319)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at android.os.Handler.dispatchMessage(Handler.java:99)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at android.os.Looper.loop(Looper.java:123)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at java.lang.reflect.Method.invokeNative(Native Method)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at java.lang.reflect.Method.invoke(Method.java:507)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  11-01 23:21:43.991: E/AndroidRuntime(442):  at dalvik.system.NativeStart.main(Native Method)
  11-01 23:21:48.481: I/Process(442): Sending signal. PID: 442 SIG: 9
  </code></pre>
  
  <p>Plz note that upto "here"(6th line), it is Log. I which i gave for checking and it is the line just before the <code>startActivity</code> function.</p>
  
  <pre><code>        Intent msg=new Intent(Intent.ACTION_SEND);
          String[] recipients={"myid@gmail.com"};
  
          msg.putExtra(Intent.EXTRA_EMAIL, recipients);
  
          msg.putExtra(Intent.EXTRA_TEXT, "This is the email body");
          msg.putExtra(Intent.EXTRA_SUBJECT, "This is the email subject");
  
          //msg.setType("message/rfc822");
          msg.setType("*/*");
  
          //context.startActivity(Intent.createChooser(msg, "This is the chooser title"));
          Log.i("msg","this is from msg");
  
          //calling into main activity
          MainActivity ma=new MainActivity();
          ma.fun(msg);
  </code></pre>
  
  <p>//this function is inside the mainActivity</p>
  
  <pre><code>public void fun(Intent send)
  {
      Log.i("sha","here");
      startActivity(Intent.createChooser(send, "This is the chooser title"));
  
      Log.i("sha","here2");
  }
  </code></pre>