tags:

views:

27

answers:

0

i am working on a application where i have image onwhich when u click it gets navigated to browser witha link but with the code. but it dont display web page. now i need a code for just displaying a simple web page in blackberry.. is it something to do with simulator and device as i am working with simulator.So kindly help me with it....I am newbie to blackberry.. thank you in advance for help.. my code is like this.....

code ` import java.io.ByteArrayOutputStream;

import net.rim.blackberry.api.browser.Browser; import net.rim.blackberry.api.browser.BrowserSession; import net.rim.device.api.io.Base64OutputStream; import net.rim.device.api.ui.component.Dialog; import net.rim.device.api.ui.container.MainScreen;

class WebView extends MainScreen { public WebView(String p_strHTML) { try { MyThread thread = new MyThread(p_strHTML); thread.start();

 } 
 catch(Exception e) 
 {
 }

}

private static class MyThread extends Thread { String m_strHTML;

 public MyThread(String p_strHTML)
 {
     m_strHTML=p_strHTML;

 }

 public void run()
 {
     try 
     {

         ByteArrayOutputStream output = new ByteArrayOutputStream();
         Base64OutputStream boutput = new Base64OutputStream( output );

         output.write( "data:text/html;base64,".getBytes() );
         boutput.write( m_strHTML.getBytes() );
         boutput.flush();
         boutput.close();
         output.flush();
         output.close();
         BrowserSession bSession = Browser.getDefaultSession();
         bSession.displayPage( output.toString() );
         bSession.showBrowser();


     }
     catch( Exception e ) 
     {
         //System.out.println( "Exception: " + e );
         Dialog.alert("Exception"+e);
     }
 }

}

}`