启动相机的问题?

时间:2010-11-19 10:05:53

标签: blackberry

我正在使用jde 4.5想通过我的应用程序使用相机。 我编写代码并获得由非事件线程引发的运行时异常Pushmodelscreen 告诉我它里面有什么问题?

public void start Camera()

 {
  try {
// Create a player for the Blackberry's camera
Player player= Manager.createPlayer( "capture://video" );
     // Set the player to the REALIZED state (see Player javadoc)
         player.realize();
         // Grab the video control and set it to the current display
         _videoControl = (VideoControl)player.getControl( "VideoControl" );
         if (_videoControl != null)
         {
             // Create the video field as a GUI primitive (as opposed to a
             // direct video, which can only be used on platforms with
             // LCDUI support.)
             _videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
             _videoControl.setDisplayFullScreen(true);
             _videoControl.setVisible(true);
         }
         player.start();
         if(_videoField!=null)
      {
       add(_videoField);
      }

} catch(例外e){     // TODO:处理异常     Dialog.alert(e.getMessage());    }      } `

thnaks很多 阿米特

1 个答案:

答案 0 :(得分:0)

应该从UI线程中调用UI更改中涉及的代码。因此,很可能应该以某种方式调用代码的某些部分:

UIApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {
        // do your UI related staff here
        // e.g. push a Screen or call Dialog.alert(), etc.
    }
});

另外,您可能会发现this info很有趣。