2010-02-09 73 views

回答

34

用动作提高意图为ACTION_GET_CONTENT,并将类型设置为“image/*”。这将启动照片选择器活动。当用户选择图像时,可以使用onActivityResult回调来获取结果。

喜欢的东西:

Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); 
photoPickerIntent.setType("image/*"); 
startActivityForResult(photoPickerIntent, 1); 

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{ 
    super.onActivityResult(requestCode, resultCode, data); 
    if (resultCode == RESULT_OK) 
    { 
     Uri chosenImageUri = data.getData(); 

     Bitmap mBitmap = null; 
     mBitmap = Media.getBitmap(this.getContentResolver(), chosenImageUri); 
     } 
} 
使用此代码我是从媒体上获得的图像什么是我的问题是,我需要存储在远程server.i上午该图像转换成mBitmap字节组,当我尝试
+0

喜samuh.by发送字节数组它是shwoing 5位数字代码我感觉它是字节数组的地址。可以请你帮忙解决这个问题 在此先感谢 Aswan – Aswan 2010-04-27 08:28:20

+1

你可能发送字节数组的HashCode而不是数组元素。 – Samuh 2010-04-27 09:12:16

+0

in = new FileInputStream(“/ sdcard/pictures/einstein3.jpg”); buf = new BufferedInputStream(in,2000); System.out.println(“1 ..................”+ buf); byte [] byteArray = new byte [buf.available()]; buf.read(byteArray); 现在我发送“bytearray”给服务器,而不是只发送哈希码发送.can你建议我在哪里我犯了错误 – Aswan 2010-04-28 07:16:17

相关问题