2010-11-19 79 views
0

我使用jde 4.5希望通過我的應用程序使用相機。 我寫的代碼和得到運行時exceletion Pushmodelscreen由非事件線程caled 告訴我它的問題是什麼?啓動相機問題?

公共無效啓動照相機()

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

}趕上(例外五){// TODO:處理異常 Dialog.alert(e.getMessage()); }} `

thnaks很多 阿米特

+0

'Pushmodelscreen caaled by non event thread' 這個錯誤通常發生在彈出屏幕或'Dialog.alert'需要在任何屏幕被推動之前顯示。 – Prasham 2010-11-19 11:01:42

回答

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有趣。