如何从android应用程序向matlab服务器发送jpg图片?

如何从android应用程序向matlab服务器发送jpg图片?,android,image,matlab,server,client,Android,Image,Matlab,Server,Client,我有一个应用程序,有一个简单的按钮,可以拍照。我想将此图片发送到matlab服务器。这是我的密码: button = (Button) findViewById(R.id.uploadButton); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Toast.makeText(MainActivity.this,"Try

我有一个应用程序,有一个简单的按钮,可以拍照。我想将此图片发送到matlab服务器。这是我的密码:

button = (Button) findViewById(R.id.uploadButton);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //Toast.makeText(MainActivity.this,"Try Toast",Toast.LENGTH_LONG).show();
            //Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
            //startActivity(intent);

            Intent cameraIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, CAMERA_REQUEST);


        }
    });
这是另一种方法:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    super.onActivityResult(requestCode, resultCode, data);

    //did the user choose ok? If so, the code inside these curly braces will execute.
    if (resultCode == RESULT_OK){
        if (requestCode == CAMERA_REQUEST){
            //we are hearing back from the camera
            Bitmap cameraImage = (Bitmap) data.getExtras().get("data");
            //at this point we have the image from the camera.
            //imgSpecimenPhoto.setImageBitmap(cameraImage);
            Bitmap bJPGcompress = codec(cameraImage, Bitmap.CompressFormat.JPEG, 100);
            imgSpecimenPhoto.setImageBitmap(bJPGcompress);
        }
    }
}

private static Bitmap codec(Bitmap img, Bitmap.CompressFormat format,
                            int quality) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    img.compress(format, quality, baos);
    byte[] array = baos.toByteArray();
    return BitmapFactory.decodeByteArray(array, 0, array.length);
}