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"));
}
这可能很有用:http://stackoverflow.com/questions/7991716/how-can-i-get-filepicker-working-properly-on-某些-黑莓手机 –