Sarah
Sarah

Reputation: 1905

BlackBerry - Open URL in Browser

On clicking the LabelField, I want to open the browser with the website link mentioned in the LabelField. I have tried to add navigation click to the LabelField but it does not work. It appears that the field is not clickable. Can anyone guide me? Below is my code for opening a browser session:

lblLink = new LabelField("www.abc.com",FIELD_LEFT)
    {
         protected void applyTheme(Graphics g, boolean arg1) 
         {
             g.setColor(Color.DEEPSKYBLUE);
             super.applyTheme(g, arg1);
         }
         protected boolean navigationClick(int status,int time)
            {
             BrowserField myBrowserField = new BrowserField();
             verticalManager.add(myBrowserField);
             myBrowserField.requestContent("http://www.abc.com");   
                return true;
            }
     };
     Font myFont1 = Font.getDefault().derive(Font.BOLD, 8, Ui.UNITS_pt);
     lblLink.setFont(myFont1);
    vr3Tab3.add(lblLink);

EDIT: I came across the fact that in order to open the website in a browser and not inside the App, we need to call Browser.getDefaultSession().displayPage("http://www.google.com");

However, this does not work for me either. Is my issue on the navigation click or in the way I am opening the browser. Please help.

Upvotes: 1

Views: 842

Answers (1)

Rince Thomas
Rince Thomas

Reputation: 4158

try this -

    label = new LabelField("http://www.google.com",LabelField.FOCUSABLE){
            public boolean navigationClick (int status , int time){
                 BrowserSession bSession = Browser.getDefaultSession();
                 bSession.displayPage(label.getText());
                 return true;
            }
        };
   add(label);

Upvotes: 3

Related Questions