0

My lwuit application is working fine on Blackberry Simulator while on device the application installs successfully, starts normally, but where am having issues is on network connection. Trying to access network I get 400 Bad Request message. I don't no what am doing wrong, my network connection code is as below:

public ConnectionRequest prepareConnection(String page, String progressMsg, final int request)
{
    final ConnectionRequest conR = new ConnectionRequest()
    {
        public void readResponse(InputStream input) throws IOException  {
            StringBuffer sb = new StringBuffer();
            int ch;
            while((ch=input.read()) != -1)
                sb.append((char)ch);

            httpResponse(sb.toString().trim(), request);
        }
    };

    conR.setUrl(NetworkHandler.getURL()+page);
    conR.setDuplicateSupported(true);
    Progress progress = new Progress(progressMsg, conR)
    {
        public void actionCommand(Command command)
        {
            if(command.getCommandName().equals("Cancel"))
                conR.kill();
        }
    };
    conR.setDisposeOnCompletion(progress);

    return conR;
}

private void login(String code)
{
    Container container = Display.getInstance().getCurrent();

    if(!validateLogin(container))
    {
        showDialogMessage("Alert", "Please enter your user name and password!");
        return;
    }
    NetworkManager.getInstance().start();

    ConnectionRequest conR = prepareConnection(NetworkHandler.LOGIN_PAGE, "Authenticating...", RequestType.LOGIN);
    Dialog dialog = conR.getDisposeOnCompletion();

    conR.setPost(true);
    conR.addArgument("u", getFieldValue(findTxtUserName(container)));
    conR.addArgument("p", getFieldValue(findTxtPassword(container)));
    conR.addArgument("c", code);

    NetworkManager.getInstance().addToQueue(conR);
    dialog.show();
}

public void onLoginForm_BtnLoginAction(Component c, ActionEvent event) {
      login("");
}

Please I want you guys to help me out. Thanks in Advance.

The login me

Charles
  • 50,943
  • 13
  • 104
  • 142
Chibuike Mba
  • 327
  • 1
  • 10

1 Answers1

1

This usually indicates a problem in APN configuration on the device. Normally Blackberry app's workaround incorrect APN configurations automatically which is a pretty difficult thing to do. CodenameOne does that seamlessly but LWUIT does not.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • @shaialmong, thanks for ur reply. I don't think if APN is the issue because other apps are working fine, connecting to network on the devices i've tested it on. In my country, network operators configure that automatically. About CodenameOne, from what I saw on their website, it seem that the project is not out yet. – Chibuike Mba Feb 23 '12 at 06:32
  • CodenameOne will be out in public beta in the first week of March. The browser has a separate definition for APN so it might work while the application fails. Did you check other device types etc. – Shai Almog Feb 23 '12 at 13:39
  • have not tested it on other device type, we have midlet version for other java enabled mobile devices. we wanted the lwuit version to be for blackberry only. can lwuit project be converted to CodenameOne project? I will test it on over devices as you suggested. – Chibuike Mba Feb 23 '12 at 22:34
  • Converting to Codename One requires some work due to different package structure/API & lifecycle. – Shai Almog Feb 24 '12 at 07:42
  • 1
    I have finally got it working, helped by [this](http://stackoverflow.com/q/9030639/774440) post. I was using Resource Editor generated jars now changed them (UI_RIM_Touch.jar and UI_RIM.jar) to LWUIT_Blackberry_4_7_OrNewer.jar, and it app is now connecting to the Internet. Thanks for your assistance. – Chibuike Mba Feb 25 '12 at 12:00