Android:从图像ID获取byte []

这是我在做的事情: 在onActivityResult中,我在Intent中获取数据。
 Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
 startActivityForResult(intent, TAKE_PICTURE);
此代码获取图像ID:
data.getData().getLastPathSegment();
现在我想使用这个图像ID来获取byte [] imageData,这样我就可以在服务器上上传图像了。 我该怎么办呢?     
已邀请:
Uri selectedImageUri = data.getData();

String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(selectedImageUri, projection, null, null, null);
cursor.moveToFirst();
selectedImagePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));
cursor.close();

try 
{
    File myFile = new File(selectedImagePath);
    int filelenghth=(int)myFile.length();
    byte [] mybytearray  = new byte [filelenghth];
    BufferedInputStream bis1 = new BufferedInputStream(new FileInputStream(myFile));

    bis1.read(mybytearray,0,mybytearray.length);

    dos.write(mybytearray,0,mybytearray.length);   // write the array to the data output stream
                                                   // or whatever else you want to do with it
    finish();
}
catch(Exception e)
{
    e.printStackTrace();
}
    
data.getData()将返回一个图像的URI。 (检查数据!=首先是null!) 那么你只需要对服务器执行http发布。 有关http post代码,请参阅以下有关SO的参考:使用Http Post发送图像     

要回复问题请先登录注册