title: How to send captures image from Android client to c#
body: <p>Going through a swear problem. This is the code i am using for android client app. I have no idea,as i want to send this captured image to c# server. Can anybody guide me or provide a code ? Have just given up searching this kind of stuff in GOOGLE! -_- 
  I will appericiate if someone help me in this regard!</p>
  
  <p>"Android code that i am using"</p>
  
  <pre><code>package net.simplifiedcoding.androidcameraapp;
  import java.io.BufferedWriter;
  
  import java.io.ByteArrayOutputStream;
  import java.io.DataOutputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.PrintStream;
  import java.io.PrintWriter;
  import java.net.InetAddress;
  
  import java.net.Socket;
  import java.net.UnknownHostException;
  import java.nio.ByteBuffer;
  import java.net.Inet4Address;
  import java.net.InetAddress;
  import java.net.Socket;
  import java.net.UnknownHostException;
  
  
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.graphics.Typeface;
  import android.graphics.drawable.BitmapDrawable;
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.GridLayout;
  import android.widget.GridView;
  import android.widget.ImageView;
  import android.widget.TableLayout;
  import android.app.Activity;
  import android.util.DisplayMetrics;
  import android.graphics.Bitmap.CompressFormat;
  import android.view.View;
  
  
  public class MainActivity extends ActionBarActivity {
  
  
  public void send_picture(View view) {
  
  
  }
  
  private Socket socket;
  
  private  static final int SERVERPORT = 1234;
  private  static  final String SERVER_IP = "My IP Address";
  
  @Override
  public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      new Thread(new ClientThread()).start();
  
      Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome-webfont.ttf" );
      btnCamera = (Button) findViewById(R.id.btnCamera);
  
      capturedImage= (ImageView) findViewById(R.id.capturedImage);
  
      btnCamera.setTypeface(font);
  
      btnCamera.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              openCamera();
          }
      });
  
  
      }
  
      public void onClick(View view) {
      try {
          ImageView imageView=(ImageView) findViewById(R.id.capturedImage);
          Bitmap bmp=((BitmapDrawable)imageView.getDrawable()).getBitmap();
  
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          bmp.compress(Bitmap.CompressFormat.JPEG,0,bos);
          byte[] array = bos.toByteArray();
  
          OutputStream out = socket.getOutputStream();
          DataOutputStream dos = new DataOutputStream(out);
          dos.writeInt(array.length);
          dos.write(array, 0, array.length);
      } catch (UnknownHostException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      }
     class  ClientThread implements Runnable {
      @Override
      public void run(){
          try {
              InetAddress serverAddr = InetAddress.getByName(SERVER_IP);
              socket = new Socket(serverAddr, SERVERPORT);
          } catch (UnknownHostException e1) {
              e1.printStackTrace();
          } catch (IOException e1) {
              e1.printStackTrace();
          }
      }
  }
  
  
  
  private Button btnCamera;
  private ImageView capturedImage;
  
  
  
  
  
  private void openCamera() {
      Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
      startActivityForResult(intent, 0);
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      // TODO Auto-generated method stub
      super.onActivityResult(requestCode, resultCode, data);
      if(resultCode == RESULT_OK) {
          Bitmap bp = (Bitmap) data.getExtras().get("data");
          capturedImage.setImageBitmap(bp);
      }
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>
  
  <p>And here's the xml file:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"&gt;
  
  &lt;Button
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="@string/camera_button"
      android:id="@+id/btnCamera"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:background="@drawable/button"
      android:textColor="#ffd3ffe5"
      android:textStyle="bold" /&gt;
  
  &lt;ImageView
      android:layout_width="fill_parent"
      android:layout_height="370dp"
      android:id="@+id/capturedImage"
      android:layout_above="@+id/btnCamera"&gt;
  
  &lt;/ImageView&gt;
  </code></pre>
  
  <p></p>