Lista via bluetooth

0 respostas
E

Alguém sabe como enviar uma lista feita num Jlist para o cliente (celular)
com este codigo abaixo?
A idéia é clicar num botão na aplicação q vai fazer a procura e quando achasse o celular
enviasse a lista.

Por favor. Já agradeço!

import java.io.IOException;   
  
import javax.bluetooth.LocalDevice;   
import javax.bluetooth.ServiceRecord;   
import javax.bluetooth.UUID;   
import javax.microedition.io.Connector;   
import javax.microedition.io.StreamConnectionNotifier;   
  
  
public class ConexaoComputador {   
    private static StreamConnectionNotifier conexao;   
    private static StreamConnectionNotifier conexaoCliente;   
  
    public static void main(String[] args) throws IOException {   
        UUID identificadorUnico = new UUID(0x1101);   
        String endereco = "btspp://localhost:" + identificadorUnico.toString() +";name=sethbrabluetooth";   
        conexao = (StreamConnectionNotifier)Connector.open(endereco);   
  
        LocalDevice dispositivo = LocalDevice.getLocalDevice();   
        String enderecoMac = dispositivo.getBluetoothAddress();   
        String canal = dispositivo.getRecord(conexao).getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);   
        System.out.println("MAC: " + enderecoMac + " canal:" + canal);   
        while(true){   
            System.out.println("Aguardando Clientes:");   
            conexaoCliente = (StreamConnectionNotifier) conexao.acceptAndOpen();   
            System.out.println("Conectou");   
        }   
    }   
  
}
cel
public class ClienteJ2Me extends MIDlet implements CommandListener {   
    private TextBox texto;   
    private Command sair;   
    private Display d;   
  
    public ClienteJ2Me() {   
        this.sair = new Command("Sair",Command.EXIT,0);   
        this.texto = new TextBox("","",40,TextField.ANY);   
        this.texto.setCommandListener(this);   
                   
           
        this.texto.addCommand(this.sair);     
        this.d = Display.getDisplay(this);   
    }   
  
    protected void destroyApp(boolean arg0){   
    }   
  
    protected void pauseApp() {   
        // TODO Auto-generated method stub   
  
    }   
  
    protected void startApp() throws MIDletStateChangeException {   
        this.d.setCurrent(this.texto);   
        StreamConnection connection = null;   
        try {   
            connection = (StreamConnection)Connector.open("btspp://001F81000100:2",Connector.READ_WRITE,false);   
            System.out.println("Conectou");   
            connection.close();   
        } catch (IOException e) {   
            this.texto.setString("Erro ao tentar conectar : " + e.getMessage());   
            e.printStackTrace();   
        }     
    }   
  
    public void commandAction(Command arg0, Displayable arg1) {   
        if(arg0 == this.sair){   
            this.destroyApp(true);   
            this.notifyDestroyed();   
        }   
    }   
  
}
Criado 28 de novembro de 2009
Respostas 0
Participantes 1