Skip to Content
0
Former Member
Nov 05, 2012 at 10:30 AM

BlackBerry connection with SUP fails.

26 Views

I cannot able to connect with SUP, My program creates de object from class Application, but when I try to some method of the class, The application throws an exception and gets close.

code used is:

public MyScreen()

{

setTitle("Login");

loginBoton = new ButtonField("Login", ButtonField.CONSUME_CLICK | ButtonField.HCENTER | Field.FIELD_HCENTER | Field.FIELD_VCENTER);

loginBoton.setChangeListener(login);

add(loginBoton);

}

FieldChangeListener login = new FieldChangeListener(){

public void fieldChanged(Field field, int context) {

if(field==loginBoton){

/*com.sybase.mobile.*/Application app = /*com.sybase.mobile.*/Application.getInstance();

// The identifier has to match the application ID deployed to the SUP server

try{

String cadena = new String ("PedidosGW");

app.setApplicationIdentifier(cadena);

PedidosGWDB.setApplication(app);

// ConnectionProperties has the infomation needed to register

// and connect to SUP server

ConnectionProperties connProps = app.getConnectionProperties();

connProps.setActivationCode("xxxxx");

connProps.setServerName("xxxxx");

connProps.setPortNumber(5001);

connProps.setFarmId("0");

// Other connection properties need to be set when connecting through relay server

// provide user credentials

// Initialize generated package database class with this Application instance

PedidosGWDB.setApplication(app);

LoginCredentials loginCred = new LoginCredentials("xxxxx", "xxxxxx");

connProps.setLoginCredentials(loginCred);

//

//PedidosGWDB.registerCallbackHandler(new MyAppCallback());

if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED){

// If the application has not been registered to the server,

// register now

app.registerApplication(30);

}

else{

// start the connection to server

app.startConnection(30);

}

}catch(Exception ex){

}

}

}

};