title: error in http post request in android
body: <p>Here is my code. I am getting error in this , please help me complete it.
   I am trying to post a http request to my server with some data in my android app.</p>
  
  <pre><code>        package com.example.firstapp;
  
  import android.app.Activity;
  import android.graphics.drawable.AnimationDrawable;
  import android.hardware.Sensor;
  import android.hardware.SensorManager;
  import android.media.MediaPlayer;
  import android.media.MediaPlayer.OnCompletionListener;
  import android.os.Bundle;
  import android.view.View;
  import android.view.animation.AlphaAnimation;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import com.example.firstapp.ShakeDetector.OnShakeListener;
  
  public class MainActivity extends Activity {
  
      private CrystalBall mCrystalBall = new CrystalBall();
      private ApiCall mApiCall = new ApiCall();
      private TextView mAnswerLabel;
      private Button mGetAnswerButton;
      private ImageView mCrystalBallImage;
      private SensorManager mSensorManager;
      private Sensor mAccelerometer;
      private ShakeDetector mShakeDetector;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          //Assign the Views from the layout file
          mAnswerLabel = (TextView) findViewById(R.id.textView1);
          mGetAnswerButton = (Button) findViewById(R.id.button1);
          mCrystalBallImage = (ImageView) findViewById(R.id.imageView1);
  
          mGetAnswerButton.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View arg0) {
                  handleNewAnswer();
                  mApiCall.postData();
              }
          });
  
          mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
          mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
          mShakeDetector = new ShakeDetector(new OnShakeListener() {
  
              @Override
              public void onShake() {
                  handleNewAnswer();
              }
          });
          //Toast.makeText(this, "Yes this is toast", Toast.LENGTH_LONG).show();
          //Log.d("Main Activity", "from oncreate() function");
      }
  
      @Override
      public void onResume() {
          super.onResume();
          mSensorManager.registerListener(mShakeDetector, mAccelerometer, 
                  SensorManager.SENSOR_DELAY_UI);
      }
  
      @Override
      public void onPause() {
          super.onPause();
          mSensorManager.unregisterListener(mShakeDetector);
      }
  
      private void animateCrystalBAll() {
          mCrystalBallImage.setImageResource(R.drawable.ball_animation);
          AnimationDrawable ballAnimtion = (AnimationDrawable) mCrystalBallImage.getDrawable();
          if(ballAnimtion.isRunning()) {
              ballAnimtion.stop();
          }
          ballAnimtion.start();
      }
  
      private void animateAnswer() {
          AlphaAnimation fadeInAnimation = new AlphaAnimation(0, 1);
          fadeInAnimation.setDuration(1500);
          fadeInAnimation.setFillAfter(true);
          mAnswerLabel.setAnimation(fadeInAnimation);
      }
  
      private void playSound() {
          MediaPlayer player = MediaPlayer.create(this, R.raw.crystal_ball);
          player.start();
          player.setOnCompletionListener(new OnCompletionListener() {
  
              @Override
              public void onCompletion(MediaPlayer mp) {
                  mp.release();
              }
          });
      }
  
  
  
  }
  </code></pre>
  
  <p>Here is ApiCall.java. In this file I am using http post request</p>
  
  <pre><code>package com.example.firstapp;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.http.HttpResponse;
  import org.apache.http.NameValuePair;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.entity.UrlEncodedFormEntity;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.message.BasicNameValuePair;
  
  import android.os.AsyncTask;
  
  public class ApiCall extends AsyncTask {
      public void postData() {
          HttpClient httpclient = new DefaultHttpClient();    
            HttpPost httppost = new HttpPost("http://dailydeal.in/android/Api.php");      
                  try {        
  
                       List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();        
                       nameValuePairs.add(new BasicNameValuePair("gmail","mail@gmail.com"));
  
                       httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
                      HttpResponse response = httpclient.execute(httppost);             
                   } 
                  catch (ClientProtocolException e) 
                  {       
                       e.printStackTrace(); 
                   } 
                  catch (IOException e) 
                  {         
                       e.printStackTrace();
                    }
      }
  
      @Override
      protected Object doInBackground(Object... arg0) {
          // TODO Auto-generated method stub
          return null;
      } 
  }
  </code></pre>