2010-02-09 77 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

相關問題