Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7087569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:41:24+00:00 2026-05-28T07:41:24+00:00

I am developping a BlackBerry application which communicates with the server via HTTP requests(

  • 0

I am developping a BlackBerry application which communicates with the server via HTTP requests(javax.microedition.io.HttpConnection). On device, user clicks some UI items, and device sends the requests to server, when the response comes, UI changes. Communication takes place under new thread, while UI thread pushes and pops ProgressDialogScreen.

The problem is sometimes, when response comes and ProgressDialogScreen is popped, UI does not change but after couple seconds UI changes. If you have requested in between when ProgressDialogScreen is popped and when new Screen is pushed, there comes the mess. First oldest new Screen is pushed, and the newest new Screen is pushed. And this situation can be observed like server responsing wrong requests. This problems occur on simulator and device.

The other problem is, sometimes two same response returns for one request. I was able to see these two problems on simulator at the logs, but i have not able to see this issue on device since i can not see the logs.

EDIT:

String utf8Response;
HttpConnection httpConn = null;
try{
    httpConn = (HttpConnection) Connector.open(url);
    httpConn.setRequestMethod(HttpConnection.GET);
    httpConn.setRequestProperty("Content-Type", "text/html; charset=UTF8");
    if(sessionIdCookie != null){
        //may throw IOException, if the connection is in the connected state.
        httpConn.setRequestProperty("Cookie", sessionIdCookie);
    }
}catch (Exception e) {
    //...
}

try{
    httpConn.getResponseCode();
    return httpConn;
}catch (IOException e) {
    // ...
}
byte[] responseStr = new byte[(int)httpConn.getLength()];
DataInputStream strm = httpConn.openDataInputStream();
strm.readFully(responseStr);
try{
    strm.close();
}catch (IOException e) {
    // ....
}
utf8Response = new String(responseStr, "UTF-8");

If this code successfully run, this piece of code runs and new screen is pushed:

UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {
       Vector accounts = Parser.parse(utf8Response,Parser.ACCOUNTS);
       if (accounts.size() == 0){
           DialogBox.inform(Account.NO_DEPOSIT);
           return;
       }
       currentScreen = new AccountListScreen(accounts);
       changeScreen(null,currentScreen);
    }
});

public void changeScreen(final AbstractScreen currentScreen,final AbstractScreen nextScreen) {
    if (currentScreen != null) 
        UiApplication.getUiApplication().popScreen(currentScreen);
    if (nextScreen != null)
        UiApplication.getUiApplication().pushScreen(nextScreen);
}

EDITv2:

private static void progress(final Stoppable runThis, String text,boolean cancelable) {
    progress = new ProgressBar(runThis, text,cancelable);
    Thread threadToRun = new Thread() {
        public void run() {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    try{
                        UiApplication.getUiApplication().pushScreen(progress);
                    }catch(Exception e){
                        Logger.log(e);
                    }
                }
            });
            try {
                runThis.run();
            } catch (Throwable t) {
                t.printStackTrace();
            }
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                 public void run() {
                    try {
                        UiApplication.getUiApplication().popScreen(progress);
                    } catch (Exception e) { }
                 }
            });
        }
   };
   threadToRun.start();
}

By the way ProgressBar is extended from net.rim.device.api.ui.container.PopupScreen and Stoppable is extended from Runnable

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:41:25+00:00Added an answer on May 28, 2026 at 7:41 am

    I preferred to pop progress bar after new Screen is prepared and pushed. This way there will be no new request between request and response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing on BlackBerry 4.7 Storm device. Reminder: My application will allow user
I am developing blackberry application using BlackBerry JDE 5.0.X , in which i am
For my university class we are developing a multi-threaded Blackberry application which allows us
I am developing a BlackBerry application where the server is in Java. Whenever AES
I am developing an application which will run on different blackberry devices. 640 x
I'm developing a blackberry application to remotely access an external customer database. Selected employees
I am developing a blackberry application and i wanted to access the websites from
I am developing a blackberry application using j2me and LWUIT (blackberry port). Everything works
I am looking into developing a small app to run on a blackberry which
I'm currently developping an application in java using Hibernate as a persistence manager and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.