开发者

sending an image to an URL in android

the following is the code which i am using to capture an image from the camera in my app

   public void startCamera() 
    {
        Log.d("ANDRO_CAMERA", "Starting camera on the phone...");
        String fileName = "testphoto.jpg";
        ContentValues values = new ContentValues();
        values.put(MediaStore.Images.Media.TITLE, fileName);
        values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera");
        values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");

        imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUA开发者_运维百科LITY, 1);
        startActivityForResult(intent, IMAGE_CAPTURE);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == IMAGE_CAPTURE) 
        {
            if (resultCode == RESULT_OK)
            {
                Log.d("ANDRO_CAMERA","Picture taken!!!");
                imageView.setImageURI(imageUri);
            }
        }
    }

after capturing the image and when i select insert it gets stored in memory but i want it to be sent to an URL and i want it to be viewed in another activity.

how to do this pls help me.....


You need the URL of the image.

  public void startCamera(){
   Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);  
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);  
  }

   Uri selectedImageUri;
   private static final int CAMERA_PIC_REQUEST = 1337; 
   @Override
public void onActivityResult(int requestCode, int resultCode, Intent intent){
        if (requestCode == CAMERA_PIC_REQUEST) { 
            selectedImageUri = Intent.getData();                        

        }  

You will be getting the URI in SelectedImageURI, then you can send that using Intent.putExtra();

This works for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜