08-17-2012 02:44 AM
I have a browserfield on screen. While navigating in browserfield i want to track urls and for a perticular url i have to push another screen. How should i do this?
08-17-2012 03:19 AM
Check with the following link
http://stackoverflow.com/questions/418105/embedded
Some pointer keyword to search in Google
08-17-2012 04:00 AM
08-17-2012 04:33 AM - edited 08-17-2012 04:42 AM
//Attach a controller to the browser field mBrowserField.getConfig().setProperty(BrowserFieldConfig.CONTROLLER, new BrowserController()); //Define actions to be done on URL calls final class BrowserController extends ProtocolController{ private String URL_TO_TRAP = "http://us.blackberry.com/devices.html"; //Called when navigating to a new URL public void handleNavigationRequest(BrowserFieldRequest request) throws Exception{ if(request.getURL().equals(URL_TO_TRAP) ){ //custom action here } super.handleNavigationRequest(request); } //Called when the browser field is loading a resource(image, script etc) public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception{ if(request.getURL().equals(URL_TO_TRAP) ){ //custom action here } return super.handleResourceRequest(request); } }
You need to attach a controller to the browserfield and check every URL that is called.
It is advisable to use "indexOf()" String comparison instead of equals to avoid clash with parameters within URL.
e.g., you want to trap call to "http://us.blackberry.com/devices.html" but the actual call could be "http://us.blackberry.com/devices.html?lid=us:bb:de
Tell me this solved your problem! ![]()
08-17-2012 05:42 AM - edited 08-17-2012 06:16 AM
thanx. I tried this with BrowserFieldListener. I got my solution.
08-17-2012 11:59 AM
08-18-2012 08:43 AM
08-21-2012 04:30 AM