私がやろうとしているのは、アプリケーションに単純な Web ページを表示することです (JavaScript、Cookie、またはスクリプトを使用せず、マウス クリックなどのイベントを検出しようとしません)。
以下のコードを使用していますが、今は空の画面しか表示されません。アプリケーションがインターネットにアクセスしていることはわかっていますが (データ転送の矢印が右上隅で点滅します)、レンダリングされない理由はわかりません。
私が使用しているコードは次のとおりです。
HttpConnectionFactory factory = new HttpConnectionFactory("www.google.ca",HttpConnectionFactory.TRANSPORT_WIFI | HttpConnectionFactory.TRANSPORT_WAP2 | HttpConnectionFactory.TRANSPORT_DIRECT_TCP);
while(true)
{
try
{
HttpConnection connection = factory.getNextConnection();
try
{
BrowserContent bc = RenderingSession.getNewInstance().getBrowserContent(connection,null,0);
Field f = bc.getDisplayableContent();
add(f);
}
catch(RenderingException e)
{
//Log the error or store it for displaying to
//the end user if no transports succeed
System.out.println("error with rendering page");
}
}
catch(NoMoreTransportsException e)
{
//There are no more transports to attempt
//Dialog.alert( "Unable to perform request" ); //Note you should never
//attempt network activity on the event thread
System.out.println("no more transport");
break;
}
}
注意すべき点:
www.versatilemonkey.com の http-connection-factory クラスを使用しているのは、抽象的な httpConnection クラスを実装しているためです。誰かが自分自身を実装する方法を教えてくれれば、それは素晴らしいことです。
getBrowserContent 関数のフラグに「0」を使用しています。rimn のドキュメントを調べましたが、説明が見つかりませんでした。
どんな助けでも大歓迎です。
ありがとう、アンキット