简体   繁体   English

如何在我的应用程序中显示黑莓设备中存在的图像

[英]how to display images present in blackberry device into my application

I am developing a blackberry application where i want to select an image present in device and display it in my application. 我正在开发一个Blackberry应用程序,我想在其中选择设备中存在的图像并将其显示在我的应用程序中。 How to do it. 怎么做。

UPDATE 更新

hi I used FilePicker to get the path of the file and i am storing it in "Selection(String)" and i am using below code to display image in my application but i am getting exception. 嗨,我使用FilePicker来获取文件的路径,我将其存储在“ Selection(String)”中,并且我正在使用以下代码在我的应用程序中显示图像,但出现异常。 can anybody tell me where i did mistake. 谁能告诉我我在哪里做错了。

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"));
        }

If your target OS is 6.0+ you can use RIM component FilePicker . 如果目标操作系统为6.0+,则可以使用RIM组件FilePicker For lower OS versions you can use also this component: File Selection Popup 对于较低的OS版本,您也可以使用此组件: File Selection Popup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM