Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

java - Unable to connect to internet in Blackberry device?

I am developing an app where i am using browser field to load html files in it. My code is as follows.

Main.java

    //pushing screen to browser field page..

public Main()
{        
    // Push a screen onto the UI stack for rendering.
    pushScreen(new WebViewController());
}  

WebViewController.java

    BrowserFieldConfig bfConfig = new BrowserFieldConfig();
    bfConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
            BrowserFieldConfig.NAVIGATION_MODE_POINTER);
    bfConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED,
            Boolean.TRUE);
    bfConfig.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);  
    bfConfig.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(0.0));
    bwf = new BrowserField(bfConfig);
    add(bwf);

    UiApplication.getUiApplication().invokeLater(new Runnable() {

        public void run() {
            // TODO Auto-generated method stub
            bwf.requestContent("local:///html/index.html");         
        }
    }, 500, false);    

All my server code & UI design is in javascript & html pages respectively which invokes from index.html page...

As per the following code it is working(executing) in simulator & getting data from server during runtime. But when i am running in BlackBerry device only UI design is loading from index.html page but not getting the data from server. I am not getting any idea whats the error is. I enabled javascript in Blackberry device also but still it is not working..

As i am new to this blackberry developing, unable to find whats there problem with my app while running in Blackberry device.

As per the following code should i have to add any external code to get data from server (like just to access internet in Blackberry device after signing)

In simulator it is working good & getting data from server. When executing in Blackberry device only main page UI (UI in index.html) is loading but not getting data from server.

Can anyone help me with this.....

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This question is variation of questions "Why I have issues with connection on the BlackBerry". I'll try to give you idea how to solve them.

The network connection is much complex unlike j2me, android or iphone connection where you mostly ask system to open TCP/HTTP/UDP connection. RIM introduced Network Transports. I'm not sure about reasons - or they wanted to give developer power to select specific transport, or because BES admins/Carriers could restrict some connections, or other reasons. But side effect that BB developer has to specify which transport he wants to use for current connection on the device. The dramatic thing that default connection is Direct TCP (through the APN carrier settings). And direct TCP works perfect on simulators. But most used connection on the BB devices are BIS-B and WiFi. Also BIS-B was unavailable for usual developer before and they just opened it for everyone recently.

Before 5.0 OS developer had huge amount of code to determine what transports are available on the device and there was loop by transports trying to open in in order. RIM introduced ConnectionFactory in 5.0 OS which provides standard mechanism to open determine available transports and open the connection (example).

You always have to use ConnectionFactory where you want to open connection. It doesn't matter if you reach remote host directly through Connector or through BrowserField. You have to use ConnectionFactory.

Dramatic thing is that even if you use it you can't reach BIS-B transport. As I mentioned before it was available only for alliance members. RIM doesn't restrict using of BIS-B for any developers right now. But I don't see that they also give any example. To allow ConnectionFactory to open BIS-B you need next line:

connFact.setTransportTypeOptions(TransportInfo.TRANSPORT_BIS_B,
        new BisBOptions("mds-public"));

This is just small summary of connections on the BlackBerries. But it should give you right direction to solve your problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...