2010-11-19 15 views
0

hie ich benutze jde 4.5 möchte die Kamera über meine App verwenden. Ich schreibe den Code und bekomme Runtime Exception Pushmodelscreen von nicht Ereignis Thread getarnt sagen Sie mir, was das Problem darin?Problem beim Starten der Kamera?

public void Start Kamera()

{ 
    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 (Exception e) { // TODO: handle Ausnahme Dialog.alert (e.getMessage()); } } `

thnaks alot Amit

+0

'Pushmodelscreen von non event thread' Dieser Fehler tritt normalerweise auf, wenn ein Popup-Bildschirm oder' Dialog.alert' angezeigt werden muss, bevor ein Bildschirm gedrückt wird. – Prasham

Antwort

0

Der Code, der in UI Änderungen beteiligt sind, sollten aus dem UI-Thread aufgerufen werden. So sind die meisten wahrscheinlich ein Teil des Codes sollten in einer Art und Weise aufgerufen werden:

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

Auch Sie interessante this info finden.

Verwandte Themen