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
Highlighted
Developer
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Browser Progress Bar

Hi,

 

I'm currently developing a Custom Browser and i want to have a progress bar like the BlackBerry Internet Browser. Any idea on how to do that? like knowing how many kb does the app is trying to download etc...  

 

Anyon tried this? 

 

Thanks! 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Browser Progress Bar

[ Edited ]
Have you tried adding status to your MainScreen of custom Browser Screen. Set the stustus with gaugeField.
Message Edited by BBDeveloper on 30-07-2009 10:44 AM

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: Browser Progress Bar

Thanks BBDeveloper. I'll try that out. How about the issue on getting the size of the page before downloading. it seems that the blackberry browser, displays the total kb and the remaining kb of the loading page. 
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Browser Progress Bar

Displaying string on that not a problem on gaugefield, but check with how do you calculate the size of data downloading etc using browserfield.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: Browser Progress Bar

I was able to add a gaugefield in my browser. now my problem is how to make it move while downloading the page and the images. 

 

i tried this one:

 

synchronized (Application.getEventLock()) {

                progressBar.setValue(x);

UiApplication.getUiApplication().repaint();

 } 

 

i also tried to invalidate the screen, but still it didn't work.

 

any idea/s? Smiley Happy Thank you very much!

 

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Browser Progress Bar

Try with InvokeLater something like this..

 

UiApplication.getApplication().invokeLater(new Runnable()
        {
           public void run()
           {
                    lblResult.setText("BB Developer");
           }

        });


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 4
Registered: ‎06-02-2009
My Device: Not Specified

Re: Browser Progress Bar

Were you able to get the progress bar working correctly? I am doing fine making the progress bar, but can't seem to figure out how to get the percentage of data/images that have been loaded. Any tips on that?

Developer
Posts: 78
Registered: ‎12-03-2009
My Device: Not Specified

Re: Browser Progress Bar

Hey!

About the progress bar you can find some inputs at http://supportforums.blackberry.com/t5/Java-Development/Sample-Please-Wait-or-Progress-Bar-Code/m-p/...

 

And how about HttpConnetion.getLenght( )? It returns the length of the content which is being provided, but be aware that it can returns -1 when the content length is not know. Then, while the resource content is fetching from the web you can check the amount of data already downloaded  and update the progress bar.

 

I never implement it, but it might be something like that:

 

 

InputStream in = httpConn.openInputStream();
int total = httpConn.getLength();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len = 0, imageSize = 0;
while (-1 != (len = in.read(buffer))) {
	baos.write(buffer);
	imageSize += len;
        int percentage = imazeSize * 100 / total;
        //update gauge field
}

 See you!

 

--
Feel free to press the kudos button on the left side to thank the user that helped you.
Please mark posts as solved if you found a solution.