Unexpected Behavior of File picker Blackberry

走远了吗. 提交于 2019-12-25 04:19:31

问题


I am working on File picker from image gallery thats working fine in my 9850 os 7 but when same app if I am deployin to 9780 Os6 Bold device it's not working.

public final class MyScreen extends MainScreen implements FieldChangeListener
 {
   Bitmap bitmap;
   ButtonField click;
   BitmapField bitmapField;
   public MyScreen()
   {
    setTitle("FilePicker Screen");
    createGUI();
       }
       private void createGUI()
        {
       add(new LabelField("Click to select the image", Field.FIELD_HCENTER));
      click=new ButtonField("Click");
        click.setChangeListener(this);
        add(click);
         bitmapField=new BitmapField();
         add(bitmapField);
          }
             private Bitmap getTheImage(String url)
               {
              Bitmap bitmap=null,scaleBitmap=null;
              InputStream inputStream=null;
             FileConnection fileConnection=null;
                try
                 {
                  fileConnection=(FileConnection) Connector.open(url);
                   inputStream=fileConnection.openInputStream();
                  byte[] data=new byte[(int)fileConnection.fileSize()];
                    data=IOUtilities.streamToBytes(inputStream);
                       inputStream.close();
                         fileConnection.close();
                          bitmap=Bitmap.createBitmapFromBytes(data,0,data.length,1);

                      scaleBitmap=new Bitmap(250, 250);
                       bitmap.scaleInto(scaleBitmap, Bitmap.FILTER_LANCZOS);
                 }
                  catch (Exception e)
                 {
                  try
                       {
                if(inputStream!=null)
                 {
                inputStream.close();
                 }
                 if(fileConnection!=null)
                  {
                   fileConnection.close();
               }
                 }
                      catch (Exception exp)
                   {
                }
                 scaleBitmap=Bitmap.getBitmapResource("noimage.png");//Your known Image;
             }
                 return scaleBitmap;
             }
            public void fieldChanged(Field field, int context)
               {
             if(field==click)
                 {
                 try
            {
                  FilePicker filePicker;
                filePicker=FilePicker.getInstance();
                   filePicker.setPath("file:///store/home/user/pictures/");
                filePicker.setListener(new Listener()
                   {
             public void selectionDone(String path)
                {
             bitmapField.setBitmap(getTheImage(path));
                }
                 });
               filePicker.show();//it show what ever you select.
                }
                     catch (Exception e)
                 {

               }
              }
                 }
               }

What I am doing wrong here?

Please help me.

来源:https://stackoverflow.com/questions/21203086/unexpected-behavior-of-file-picker-blackberry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!