title: Why my android send email intent method isn't work
body: <p>Hi all I'm a newbie for android programmer.
  I have build send email intent method with status of GPS. I have a one button if user click this button i have if function to check status of GPS. and send email but send email by intent is not work and in LogCat has show this error</p>
  
  <pre><code>    07-16 16:23:30.161: E/AndroidRuntime(28567): FATAL EXCEPTION: main
  07-16 16:23:30.161: E/AndroidRuntime(28567): java.lang.IllegalStateException: Could not execute method of the activity
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.view.View$1.onClick(View.java:3735)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.view.View.performClick(View.java:4354)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.view.View$PerformClick.run(View.java:17961)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.os.Handler.handleCallback(Handler.java:725)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.os.Handler.dispatchMessage(Handler.java:92)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.os.Looper.loop(Looper.java:137)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.app.ActivityThread.main(ActivityThread.java:5328)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at java.lang.reflect.Method.invoke(Method.java:511)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at dalvik.system.NativeStart.main(Native Method)
  07-16 16:23:30.161: E/AndroidRuntime(28567): Caused by: java.lang.reflect.InvocationTargetException
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at java.lang.reflect.Method.invoke(Method.java:511)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.view.View$1.onClick(View.java:3730)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    ... 11 more
  07-16 16:23:30.161: E/AndroidRuntime(28567): Caused by: java.lang.IllegalArgumentException: Plain text must be supplied if HTML text is supplied
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.content.ClipData$Item.&lt;init&gt;(ClipData.java:252)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.content.Intent.migrateExtraStreamToClipData(Intent.java:7253)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.content.Intent.migrateExtraStreamToClipData(Intent.java:7234)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1428)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.app.Activity.startActivityForResult(Activity.java:3430)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.app.Activity.startActivityForResult(Activity.java:3391)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.app.Activity.startActivity(Activity.java:3626)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at android.app.Activity.startActivity(Activity.java:3594)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    at com.mpa.emvi.HomeActivity.sendEmail(HomeActivity.java:100)
  07-16 16:23:30.161: E/AndroidRuntime(28567):    ... 14 more
  </code></pre>
  
  <p>OK In my HomActivityClass is</p>
  
  <pre><code>    package com.mpa.emvi;
  
  import com.mpa.emvi.R;
  import android.support.v4.app.FragmentActivity;
  import android.util.Log;
  import android.view.View;
  import android.widget.Toast;
  
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.SupportMapFragment;
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
  import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
  import com.google.android.gms.location.LocationClient;
  import com.google.android.gms.location.LocationListener;
  
  import android.content.Context;
  import android.content.Intent;
  import android.location.Location;
  import android.location.LocationManager;
  import android.os.Bundle;
  
  
  public class HomeActivity extends FragmentActivity 
   implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener {
  
  
      private LocationManager mLocationManager;
      boolean statusOfGPS;
      private GoogleMap mMap;
      private LocationClient mLocationClient;
      private String DescribText = new String();
  
      private static final String TAG = "MyGPS_status";
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_home);        
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          setUpMapIfNeeded();
          setUpLocationClientIfNeeded();
          mLocationClient.connect();
          mLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE );
      }
  
      private void setUpMapIfNeeded() {
          // Do a null check to confirm that we have not already instantiated the map.
          if (mMap == null) {
              // Try to obtain the map from the SupportMapFragment.
              mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                      .getMap();
              // Check if we were successful in obtaining the map.
              if (mMap != null) {
                   mMap.setMyLocationEnabled(true);
              }
          }
      }
  
      private void setUpLocationClientIfNeeded() {
          if (mLocationClient == null) {
            mLocationClient = new LocationClient(
                getApplicationContext(),
                this,  // ConnectionCallbacks
                this); // OnConnectionFailedListener
          }
       }
  
      public void sendEmail(View view){
          statusOfGPS = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
          Intent i = new Intent(Intent.ACTION_SEND);
  
          if (mLocationClient != null &amp;&amp; mLocationClient.isConnected() &amp;&amp; statusOfGPS == true) {
              DescribText = "This is My Emergency Location on GPS " +
                      "&lt;a href='https://maps.google.com/maps?q='"+mLocationClient.getLastLocation().getLatitude()+"','"+mLocationClient.getLastLocation().getLongitude()+"'&amp;ll='"+mLocationClient.getLastLocation().getLatitude()+"','"+mLocationClient.getLastLocation().getLongitude()+"'&amp;z=17'&gt;click here&lt;/a&gt;";
  
              i.setType("text/html");
              i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"suphawut@mpatmail.com"});
              i.putExtra(Intent.EXTRA_SUBJECT, "Emergency Location");
              i.putExtra(Intent.EXTRA_HTML_TEXT   , DescribText);
              try {
                  startActivity(Intent.createChooser(i, "Send mail..."));
              } catch (android.content.ActivityNotFoundException ex) {
                  Toast.makeText(getApplicationContext(), "There are no email clients installed.", Toast.LENGTH_LONG).show();
              }
  
           Log.d(TAG, "gps =" + statusOfGPS);
          }else{
              DescribText = "This is My Emergency Location on INTERNET" +
                      " &lt;a href='https://maps.google.com/maps?q='"+mLocationClient.getLastLocation().getLatitude()+"','"+mLocationClient.getLastLocation().getLongitude()+"'&amp;ll='"+mLocationClient.getLastLocation().getLatitude()+"','"+mLocationClient.getLastLocation().getLongitude()+"'&amp;z=17'&gt;click here&lt;/a&gt;";
  
              i.setType("text/html");
              i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"suphawut@mpatmail.com"});
              i.putExtra(Intent.EXTRA_SUBJECT, "Emergency Location");
              i.putExtra(Intent.EXTRA_HTML_TEXT   , DescribText);
              try {
                  startActivity(Intent.createChooser(i, "Send mail..."));
              } catch (android.content.ActivityNotFoundException ex) {
                  Toast.makeText(getApplicationContext(), "There are no email clients installed.", Toast.LENGTH_LONG).show();
              }
  
            Log.d(TAG, "gps =" + statusOfGPS);                 
          }
      }
  
  
      @Override
      protected void onPause() {
          super.onPause();
  
      }
  
      /**
       * Callback called when disconnected from GCore. Implementation of {@link ConnectionCallbacks}.
       */
      @Override
      public void onDisconnected() {
        // Do nothing
      }
  
      /**
       * Implementation of {@link OnConnectionFailedListener}.
       */
      @Override
      public void onConnectionFailed(ConnectionResult result) {
        // Do nothing
      }
  
      @Override
      public void onLocationChanged(Location arg0) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onConnected(Bundle arg0) {
          // TODO Auto-generated method stub
  
      }
      public void onProviderEnable(String provider){
  
      }
  }
  </code></pre>
  
  <p>The send email by intent is in sendEmail method why this work?</p>
  
  <p>P.S. my English skill is poor and Thank for any answers.</p>