2011-11-29 137 views
0

我正在開發一個黑莓應用程序,我要選擇設備中存在的圖像並將其顯示在我的應用程序中。怎麼做。如何在BlackBerry應用程序中顯示圖像到我的應用程序

UPDATE

您好我用FilePicker獲得文件的路徑,我將它存儲在「選擇(字符串)」 ,我使用下面的代碼在我的應用程序來顯示圖像,但我得到異常。有誰可以告訴我我犯了什麼錯誤。

try { 
      FileConnection fconn = (FileConnection)Connector.open(selection,Connector.READ); 
      // If no exception is thrown, then the URI is valid, but the file may or may not exist. 
      if (fconn.exists()) { 
       InputStream input = fconn.openInputStream(); 
       int available = input.available(); 
       byte[] data = new byte[available]; 
       input.read(data, 0, available); 
       EncodedImage image = EncodedImage.createEncodedImage(data,0,data.length); 
       Bitmap b = image.getBitmap(); 
       BitmapField picture = new BitmapField(b); 
       add(picture); 
       add(new LabelField("Data Length:" + data.length)); 
      } 
      else { 
       add(new LabelField("Picture does not exist")); 
      } 
      fconn.close(); 
     } 
     catch (Exception ioe) { 
      add(new LabelField("Error")); 
     } 
+0

這可能很有用:http://stackoverflow.com/questions/7991716/how-can-i-get-filepicker-working-properly-on-某些-黑莓手機 –

回答

1

如果你的目標是OS 6.0及以上版本,您可以使用RIM組件FilePicker。 對於較低的操作系統版本,您也可以使用此組件:File Selection Popup

相關問題