2010-11-19 5 views
0

hie j'utilise jde 4.5 voulez utiliser la caméra via mon application. j'écris le code et obtient l'exception d'exécution Pushmodelscreen caaled par le fil de non-événement dites-moi quel est le problème dedans?problème dans le démarrage de la caméra?

Caméra début public void()

{ 
    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 : poignée exception Dialog.alert (e.getMessage()); }} `

thnaks alot Amit

+0

'Pushmodelscreen caalé par un thread non événementiel Cette erreur se produit généralement lorsqu'un écran contextuel ou' Dialog.alert' doit être affiché avant qu'un écran ne soit poussé. – Prasham

Répondre

0

Le code impliquant des modifications de l'interface utilisateur devrait être appelé à partir du thread d'interface utilisateur. Donc, très probablement une partie de votre code doit être appelé de manière:

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

En outre, vous trouverez peut-être this info intéressant.