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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

URL not getting correctly displayed?

Hi,

 

I am using below code to display url to EditField  :

public class MyBrowserFieldListener extends BrowserFieldListener
{
    /**
     * @param browserField - The BrowserField to which the document belongs
         * @param document - The document for which this event belongs.
     *            Can be null or partially created depending on when the abort occurred.
     */
    public void documentAborted(BrowserField browserField, Document document) throws Exception
    {
        logFile.log("******************");
        logFile.log("Document Aborted");
        if ((browserField != null) && (document != null))
        {
            String title = browserField.getDocumentTitle();
            logFile.log("Title ----> " + title);
            final String url = document.getBaseURI();
            logFile.log("URL ----> " + url);
            UiApplication.getUiApplication().invokeAndWait(new Runnable()
            {    
                public void run()
                {
                    BrowserTest.textField.setText(url);
                }
            });
            
            browserField.getErrorHandler().displayContentError(url, "Aborted loading document '" + title + "'");
        }
        logFile.log("******************");
        super.documentAborted(browserField, document);
    }
     
    /**
     * @param browserField - The BrowserField to which the document belongs
         * @param scriptEngine - The ScriptEngine associated with the document
         * @param document - The document for which this event belongs.
     *             At this point the document will be a new and empty document object.
     */
    public void documentCreated(BrowserField browserField, ScriptEngine scriptEngine, Document document) throws Exception
    {
        logFile.log("******************");
        logFile.log("Document Created");
        if ((browserField != null) && (document != null))
        {
            String title = browserField.getDocumentTitle();
            logFile.log("Title ----> " + title);
            String url = document.getBaseURI();
            logFile.log("URL ----> " + url);
            System.out.println("[" + this.getClass().getName() + "] Document '" + title + "' created for URL " + url);
        }
        logFile.log("******************");
        super.documentCreated(browserField, scriptEngine, document);
    }
               
    /**
     *
     * @param browserField - The BrowserField to which the document belongs
         * @param document - The document for which this event belongs.
     */
    public void documentError(BrowserField browserField, Document document) throws Exception
    {
        logFile.log("******************");
        logFile.log("Document Error");
        if ((browserField != null) && (document != null))
        {
            String title = browserField.getDocumentTitle();
            logFile.log("Title ----> " + title);
            String url = document.getBaseURI();
            logFile.log("URL ----> " + url);
            browserField.getErrorHandler().displayContentError(url, "Error loading document '" + title + "'");
        }
        logFile.log("******************");
        super.documentError(browserField, document);
    }
    
    /**
     *
     * @param browserField - The BrowserField to which the document belongs
         * @param document - The document for which this event belongs.
     */
    public void documentLoaded(BrowserField browserField, Document document) throws Exception
    {
        logFile.log("******************");
        logFile.log("Document Loaded");
        if ((browserField != null) && (document != null))
        {
            String title = browserField.getDocumentTitle();
            logFile.log("Title ----> " + title);
            String url = document.getBaseURI();
            logFile.log("URL ----> " + url);
            System.out.println("[" + this.getClass().getName() + "] Document '" + title + "' loaded");
        }
        logFile.log("******************");
        super.documentLoaded(browserField, document);
    }
               
    /**
     *
     * @param browserField - The BrowserField to which the document belongs
         * @param document - The document for which this event belongs.
     */
    public void documentUnloading(BrowserField browserField, Document document) throws Exception
    {
        logFile.log("******************");
        logFile.log("Document Unloading");
        if ((browserField != null) && (document != null))
        {
            String title = browserField.getDocumentTitle();
            logFile.log("Title ----> " + title);
            String url = document.getBaseURI();
            logFile.log("URL ----> " + url);
            System.out.println("[" + this.getClass().getName() + "] Document '" + title + "' unloading");
        }
        logFile.log("******************");
        super.documentUnloading(browserField, document);
    }

    /**
     *
     * @param browserField - The BrowserField to which the document belongs
         * @param event - The details the download progress
     */
    public void downloadProgress(BrowserField browserField, ContentReadEvent event) throws Exception
    {
        logFile.log("******************");
        logFile.log("Document Progress");
        if ((browserField != null) && (event != null))
        {
            String title = browserField.getDocumentTitle();
            logFile.log("Title ----> " + title);
            double amtComplete = event.getItemsRead() / event.getItemsToRead();
            System.out.println("[" + this.getClass().getName() + "] Document '" + title + "' loading " + String.valueOf(amtComplete) + "% complete");
        }
        logFile.log("******************");
        super.downloadProgress(browserField, event);
    }
}


This code working fine on simulator, but when i test it on a device, it will display wrong


for ex: on google search i enter wikipedia and then open it its URL should be http://www.wikipedia.org/

but it displaying like http://google.com/url?q=http://www.wikipedia.org/ something like this and same is issue with other search engines..

 

So, Please help me on this so that i am able to display correct URL

 

Thanks