03-06-2013 03:21 AM
I am working on an app for blackberry(jre 6.o & os 7.x) using browse field and app is working fine. One thing I want that, when click on a link in app and link url(domain) is different from the url which is invoked in app using browse field, open link in native blackberry browser. Please help me how to do this. Thanks.
03-06-2013 04:28 AM
In your protocol controller (the class that extends ProtocolController and you use to supply content to the browserField) you can check in the
method for URLs you wish to send to the External Browser. Then start it from there.
However in this method you do have to supply content to the browserField. So you can just create a simple html page saying "redirected to external Browser", and supply that.
03-07-2013 02:51 AM
03-07-2013 04:50 AM
I did this a while ago and am now not 100% that what I did was correct. I am wondering if using handleNavigationRequest() is the more correct way to do it, but I don't think so. My method works for me and it also appears that the proposed solution does not work for other people.
Basically using the code given in the link, you will see that handleResourceRequest() returns an InputConnection. But before you return this data, you should check the requested URL, If this URL is local to the device, then return the same as it currently does.
If the URL is not going to be supplied locally, then you just run the code that is currently in handleNavigationRequest()
BrowserSession b = Browser.getDefaultSession();
This will start the Browser. However you need to return an InputConnection from handleResourceRequest() - the BrowserField is expecting to display something. So you can return this:
String pageData = "<html><body>Accessing external Content - see Browser<br /></body></html>
return new BrowserFieldResponse(resourceURI, pageData.getBytes(), HttpProtocolConstants.CONTENT_TYPE_TEXT_HTML);
Hopefully this will get you going