Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 207
Registered: ‎09-10-2010
My Device: Not Specified

Detect requested URL in BrowserField

Hi

 

How can I detect requested URL in BrowserField when user clicks on any link in my web page? Is there any listener? 

 

Another question, is it possible to stop connection (do not fetch content) for some particular urls? 

 

Thank You.

Trusted Contributor
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: Detect requested URL in BrowserField

Below code work  for your first requirement.

 

arrow=new BitmapField(Bitmap.getBitmapResource("next.png"),BitmapField.FOCUSABLE)
            {
                protected boolean navigationClick(int status,int time)
                {
                 
                    Browser.getDefaultSession().displayPage("http://www.google.com");
                    return true;
                } 
            };
            add(arrow);

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Detect requested URL in BrowserField

[ Edited ]

I've done something like this, though it was a while ago and my memory has gone.  I can look up the code if you want.  However I think you will find that the session Dev 57, from the North American DevCon covers this area, and will probably describe it better than I could.  So I suggest you download it, which you can do from here:

(it was on Day 3).

 

If you still have problems, come back to us.

 

Edit:

I forgot to put the link in, here it is now:

https://bdsc.webapps.blackberry.com/bdsc/?iid=bdsc_DevZoneLogin&lang=na#devcon

Developer
Posts: 207
Registered: ‎09-10-2010
My Device: Not Specified

Re: Detect requested URL in BrowserField


@Hardikhamar
Thanks for reply. Unfortunately u didn't get my question.

@Peter
Thanks for suggesting that session. I will watch that session.
Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Detect requested URL in BrowserField

Attach a BrowserFieldListener with the BrowserField.addListener.

 

Scott

Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Detect requested URL in BrowserField

Also check out BrowserFieldResourceRequestHandler and BrowserFieldNavigationRequestHandler.

 

Scott