2011-10-18 7 views
1

アプリケーションからブラウザを表示する必要があります。 アプリケーションはバックグラウンドで実行する必要があり、ブラウザはフォアグラウンドになるはずです。プログラムでブラウザを呼び出す

int moduleHandle = 
     CodeModuleManager.getModuleHandle("net_rim_bb_browser_daemon"); 
    if (moduleHandle > 0) 
    { 
     // Use the default browser application descriptor as the 
     // model descriptor. 
     ApplicationDescriptor[] browserDescriptors = 
      CodeModuleManager.getApplicationDescriptors(moduleHandle); 

     // Create the new application descriptor. 
     String[] args = {"url", url, null}; 

     // Turn off auto restart (the original descriptor has it 
     // turned on) so we don't end up in a never ending loop of 
     // restarting the browser. 
     int flags = browserDescriptors[0].getFlags()^
      ApplicationDescriptor.FLAG_AUTO_RESTART; 
     ApplicationDescriptor newDescriptor = 
      new ApplicationDescriptor 
      (
       browserDescriptors[0], 
       "BrowserPS", 
       args, 
       null, 
       -1, 
       null, 
       -1, 
       flags 
      ); 

     // Run the application. 
     try 
     { 
      ApplicationManager.getApplicationManager(). 
       runApplication(newDescriptor); 
     } 
     catch (ApplicationManagerException ame) 
     { 
      System.err.println(ame.toString()); 
     } 
    } 

これは、実際のデバイス上のシミュレータでは正常に動作しますが、いない私のコードです。ヘルプは です。

+2

のように試してみてくださいあなたはまだ 'net.rim.blackberry.api.browser.Browser'と' net.rim.blackberry.api.browser.BrowserSession'クラスを見たことがありますか? –

答えて

1

BrowserSession browserSession = Browser.getDefaultSession(); 
    browserSession.displayPage(URL); 
関連する問題