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
Contributor
yugyn_lonewolf
Posts: 15
Registered: ‎09-02-2010
My Device: Not Specified

Re: Connector - problem with WiFi

I post this very simple project:

/*
 * Main.java
 *
 * © <your company here>, <year>
 * Confidential and proprietary.
 */

package xxx.testconnection;




/**
 * 
 */
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;


public class Main extends UiApplication {      

    public static void main(String[] args) {
        new Main().enterEventDispatcher();        
    }

    private Main() { 
        pushScreen(new Screen());
    }

}
 

 

/*
 * Screen.java
 *
 * © <your company here>, <year>
 * Confidential and proprietary.
 */

package xxx.testconnection;




/**
 * 
 */
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.Field;
import javax.microedition.io.*;

public class Screen extends MainScreen  {
    
    public static String CON_BIS = ";deviceside=false;ConnectionType=mdspublic";
    public static String CON_BES = ";deviceside=false";
    public static String CON_TCPIP = ";deviceside=true";
    public static String CON_WIFI = ";interface=wifi";

    private ButtonField btnWIFI;
    private ButtonField btnBIS;
    private ButtonField btnBES;
    private ButtonField btnTCPIP;
    private ButtonField btnNothing;

    Screen() { 

        setTitle("Test connection");
        
        btnWIFI = new ButtonField("Test WiFi");
        btnBIS = new ButtonField("Test BIS");
        btnBES = new ButtonField("Test BES");
        btnTCPIP = new ButtonField("Test TCPIP");
        btnNothing = new ButtonField("Test Nothing");

        add(new LabelField(""));
        add(btnWIFI);
        add(btnBIS);
        add(btnBES);
        add(btnTCPIP);
        add(btnNothing);

    }

    
    public boolean keyChar(char key, int status, int time) {
        switch (key) {
            case Characters.ENTER: case Characters.SPACE: case Characters.CONTROL_SELECT:
                execOperation();
                break;
        }
        return super.keyChar(key, status, time);
    }
   

    protected boolean navigationClick(int status, int time) {
        execOperation();
        return true;
    }


    private void execOperation() {
        
        if(btnWIFI.isFocus()) {
            // WiFi
            testConnection(CON_WIFI);
        } else if(btnBIS.isFocus()) {
            // Bis
            testConnection(CON_BIS);
        } else if(btnBES.isFocus()) {
            // Bes
            testConnection(CON_BES);            
        } else if(btnTCPIP.isFocus()) {
            // TCPIP
            testConnection(CON_TCPIP);
        } else if(btnNothing.isFocus()) {
            // Nothing (for simulator)
            testConnection("");
        }
        
    }
    
    
    private void testConnection(final String connectionType) {
        
        String url = "http://www.blackberry.com";
        try {
            HttpConnection httpConnection = (HttpConnection)Connector.open(url + connectionType, Connector.READ_WRITE, true);
            httpConnection.close();
            httpConnection = null;
            Dialog.alert("OK!!!");
        } catch(Exception e) {
            Dialog.alert(e.toString());
        }
        
    }

    
}

 

 

I have one button for any connection type.

I have tested this app whit these devices, after to remove the battery:

 

BB 9800, firmware 6, SIM without BIS/BES profile (and WiFi connection)

 

Test WiFi:  OK!!!
Test BIS:  error (correct) - java.io.IOException: invalid url parameter
Test BES:  error (correct) - java.io.IOException: invalid url parameter
Test TCPIP:  error (correct) - java.io.IOException: APN is not specified
Test Nothing:  error (correct) - java.io.IOException: APN is not specified


BB 9700, firmware 5, SIM with BIS profile (and WiFi connection)

 

Test WiFi:  OK!!!
Test BIS:  OK!!!
Test BES:  error (correct) - java.io.IOException: invalid url parameter
Test TCPIP:  error (correct) - java.io.IOException: APN is not specified
Test Nothing:  error (correct) - java.io.IOException: APN is not specified

 

It's all correct...

I have used the app with the first device and it's works fine.

I have set the app in background, opened another app, waiting and clicking the "Test WiFi" button without problemas.

I did the same test with the second device (SIM with BIS profile) and also works fine.

 

But...

Waiting more minutes without use the device, clicking the "Test WiFi" button the first device generate the error!!!

The second device works fine...

 

Well, i have now 3 differences:

- the firmware (6 and 5)

- the model (9800 and 9700)

- the SIM (Wind without any profile, Vodafone with BIS)

 

I have tested the app with another device using the SIM without any profile and a 9780 device.

But the problem appears, the error "java.io.IOException" appears...

 

I have tested the app into second device with the first SIM (without any service).

The app works fine (so it seems)!

 

Any idea???

Is possible that the problem is the firmware 6 or these models?

 

Please use plain text.