1

hi i have an image which is taken from andorid by calling image _capture how do i upload it to a windows server?

        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
             startActivityForResult(intent, 0);


      public void onActivityResult(int requestCode, int resultCode, Intent data) {

 super.onActivityResult(requestCode, resultCode, data);


 if (resultCode == RESULT_CANCELED) {
 Toast toast = Toast.makeText(this,"camera cancelled", 10000);
 toast.show();
 return;
 }

// lets check if we are really dealing with a picture

 if (requestCode == 0 && resultCode == RESULT_OK)
 {

     Bundle extras = data.getExtras();
        Bitmap b = (Bitmap) extras.get("data");
        //setContentView(R.layout.main);

        ImageView mImg;
        mImg = (ImageView) findViewById(R.id.head);
        mImg.setImageBitmap(b);
   // save image to gallery
     String timestamp = Long.toString(System.currentTimeMillis());
     MediaStore.Images.Media.insertImage(getContentResolver(), b, timestamp, timestamp);

 }
DevelopingChris
  • 39,797
  • 30
  • 87
  • 118
Srikanth Naidu
  • 787
  • 5
  • 16
  • 28

2 Answers2

2

Here's exactly what you need to do How to send HTTP POST request and receive response?

You may take a look at this article also http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload. POST upload example should help.

Community
  • 1
  • 1
Fedor
  • 43,261
  • 10
  • 79
  • 89
1

I'd suggest you to let the image capture activity be called from the gallery activity. The reason is you will have full sized image that'll be stored on default location, so When you finish gallery activity, you will have path to that full sized image. Intent is not designed to pass the huge file to another activity. Also I've seen that image taken by the camera (by android.media.action.IMAGE_CAPTURE) are of small sized. So refer to my blog that helps you to complete image capture and uploading tasks.

Vikas
  • 24,082
  • 37
  • 117
  • 159