OI pessoal tudo bom!?
Pessoal eu tenho este codigo aqui, de um exemplo que peguei em uma revista.. Eh um exemplo de conexao http com superwaba. Eu fiz tudo direitinho, ele nao me retorna erro nenhum. Porem quando coloco ele no emulador do palmos, ele nao da erro, mas quando tento listar os filmes.. ele nao consegue achar uma conexao http.. o conexao.isOpen() fica me retornando false.. vou colocar os codigos aqui.. Se alguem puder me ajudar.
package cine;
import waba.sys.Settings;
import waba.sys.Vm;
import waba.ui.ControlEvent;
import waba.ui.Event;
import waba.ui.MenuBar;
import waba.ui.MessageBox;
import waba.ui.MainWindow;
public class principal extends MainWindow {
private MenuBar menu;
static String plataforma = Settings.platform;
public principal() {
super("Cinemaz", TAB_ONLY_BORDER);
setDoubleBuffer(true);
if (plataforma.compareTo("PalmOS") == 0)
Settings.setUIStyle(waba.sys.Settings.PalmOS);
}
public void onStart() {
Vm.interceptSystemKeys(Vm.SK_ALL|Vm.SK_LAUNCH);
String col0[] = {"Cinemaz","Filmes em Cartaz","Sair"};
String col1[] = {"Info","Sobre Cartaz 1.0","Sobre SuperWaba VM"};
setMenuBar(menu = new MenuBar(new String[][]{col0,col1}));
}
public void onEvent(Event event) {
switch (event.type) {
case ControlEvent.WINDOW_CLOSED: {
if (event.target == menu) {
switch (menu.getSelectedMenuItem()) {
case -1:
break;
case 1:
FormListaFilmes formListaFilmes = new FormListaFilmes("Em Cartaz",BORDER_SIMPLE);
formListaFilmes.popupBlockingModal();
break;
case 2:
exit(0);
break;
case 101:
new MessageBox("Sobre Cinemaz 1.0","O proposito desta aplicacao | " +
"e prover acesso acesso rapido " +
"aos filmes | em cartaz no cinema" +
"mais proximo ").popupModal();
break;
case 102:
new MessageBox("Sobre SuperWaba","Hehehehe | " +
"e prover acesso acesso rapido " +
"aos filmes | em cartaz no cinema" +
"mais proximo ").popupModal();
break;
}
break;
}
}
}
}
}
package cine;
import superwaba.ext.xplat.io.http.HttpStream;
import superwaba.ext.xplat.io.http.URI;
import waba.ui.Edit;
import waba.ui.Button;
import waba.ui.ControlEvent;
import waba.ui.Event;
import waba.ui.ListBox;
import waba.ui.Window;
public class FormListaFilmes extends Window {
Button btnFechar, btnListar;
ListBox lbxFilmes;
public FormListaFilmes() {
super();
}
public FormListaFilmes(String title, byte borderStyle) {
super(title,borderStyle);
setRect(CENTER, CENTER, 140, 140);
lbxFilmes = new ListBox();
lbxFilmes.setRect(LEFT+2,24,136,96);
lbxFilmes.add("hehehe");
add(lbxFilmes);
btnListar = new Button("Listar");
btnListar.setRect(LEFT+2,BOTTOM-22,50,15);
add(btnListar);
btnFechar = new Button("Fechar");
btnFechar.setRect(55,BOTTOM-22,50,15);
add(btnFechar);
}
public void onEvent(Event event) {
switch (event.type) {
case ControlEvent.PRESSED: {
if (event.target.equals(btnFechar)) {
this.unpop();
} else if (event.target.equals(btnListar)) {
listarFilmes();
}
}
}
}
private void listarFilmes() {
lbxFilmes.removeAll();
String endereco = "http://faces.eti.br/arquivos/emcartaz.txt";
HttpStream.Options options = new HttpStream.Options();
options.readTimeOut = 60000;
options.doGet = true;
HttpStream conexao = new HttpStream(new URI(endereco), options);
byte buffer[] = new byte[5000];
String filme ="";
lbxFilmes.add("hehehe1"+conexao.isOk());
if (conexao.isOk()) {
lbxFilmes.add("hehehe2");
conexao.readBytes(buffer, 0, buffer.length);
String dados = new String(buffer);
for (int pos = 0; pos != dados.length()-1; pos++) {
if (dados.charAt(pos) == ';') {
lbxFilmes.add(filme);
filme = "";
pos++;
}
filme += dados.charAt(pos);
}
}
lbxFilmes.repaintNow();
}
}
Ele roda tudo direitinho.. so que nao sei porque nao estabelece a conexao.. e nem me retorna erro nenhum.. quando a conexai esta loqueada no emulador palm ele mostra um erro.. mas.. ele esta aceitando conexoes... :cry:
valeww



