Nao consigo conectar a Internet!

Fiz uma aplicacao que se conecta com uma aplicacao web.

Na minha maquina funciona Normal, mas quando instalo no celular

e tento execulta no celular nao funciona.

Alguem sabe o porque ?

Valeu…

Verifique se seu celular esta configurado para acesso a internet. Geralmente há uma configuração de GPRS ou
CSD que faz a conexão pela internet.
Coloque o erro que que aparece no celular para avaliarmos…

Nao aparece nenhun erro,
meu celular é um Motorola L6.

Verifique se voce consegue acessar a internet com o browser do seu celular…se conseguir…não há porque nao funcionar sua aplicação…
Me passe o trecho de codigo que voce esta chamando a url na sua aplicação…

Applicacao de Teste para qualquer URL


import java.io.InputStream;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.HttpsConnection;
import javax.microedition.io.file.FileConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class Web extends MIDlet implements CommandListener, Runnable {
    private Form tela = new Form(" W E B");
    public static Display display ;
    private Command cmAtualizar = new Command("Limpar", Command.SCREEN,2);
    private Command cmGo = new Command("Ir", Command.SCREEN,1);
    private Command cmImagem = new Command("Imagem", Command.SCREEN,3);
    TextField url = null;
    static Form tef;
    String erro = null;    
    
    private void ler(String url){
    
        try{
            HttpsConnection http = conexaoFactory.getConexaoWeb(url);
			int tam = (int)http.getLength();            
            System.out.println("Tam " + tam);
            System.out.println("Code: " + http.getResponseCode());
            if (http.getResponseCode() == HttpConnection.HTTP_OK) {
                System.out.println("OK");
                erro = " OK " ;
            } else {
                System.out.println("NAO " + http.getResponseCode());
                erro = " ERRO: " + http.getResponseCode();
            }            
            byte[] valor = new byte[tam];
            InputStream im = http.openInputStream();
            im.read(valor);
            String texto = new String(valor);            
            if (valor.equals("FABIO AURELIO")) {
                tela.append("---OK---");
                tela.append("Valor: " + texto);
            } else {
                tela.append("---NAO---");
                tela.append("Valor: " + texto);
            }            
            //tela.setTicker(new Ticker("Bacno: "+http.getURL()));
            //tela.append(new StringItem("-",new String(valor)));
            //display.setCurrent(tela);
            
        } catch(Exception e) {
            Alert al = new Alert("Erro Ler: " ,  e.getClass() + " " + e.getMessage() + " " +e , null, 			 AlertType.CONFIRMATION);
            al.setTimeout(3000);
            Web.display.setCurrent(al);
        }
        
    }
    
    public Web() {
        //ler("estoque/page/nao.txt");
        display = Display.getDisplay(this);
        url = new TextField("URL: ","http://www.google.com.br/", 100, TextField.ANY);
        tela.append(url);
        tela.addCommand(cmAtualizar);
        tela.addCommand(cmGo);
        tela.setCommandListener(this);
        tef = tela;
    }
    
    protected void startApp() throws MIDletStateChangeException {
        display.setCurrent(tela);
    }
    
    protected void pauseApp() {
        
        
    }
    
    protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
        
        
    }
    
    public void commandAction(Command arg0, Displayable arg1) {
        
        if (arg0 == cmGo) {
            Thread tre = new Thread(this);
            tre.start();
        
        }
        if (arg0 == cmAtualizar) {
            tela.deleteAll();
            tela.append(url);
        }
        
        
    }
    
    public void run() {        
        ler(url.getString());
        System.out.println("FIM");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        
    }
    
}


import com.sun.kvem.netmon.HttpAgent;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.HttpsConnection;
import javax.microedition.io.file.FileConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;

public class conexaoFactory {    
    conexaoFactory(){
        
    }    
    public static HttpsConnection getConexaoWeb(String url_2){
        HttpsConnection http = null;
        try {
            http = (HttpsConnection) Connector.open(url_2, Connector.READ);
            http.setRequestMethod(HttpConnection.GET);            
        } catch (Exception e) {
            Alert al = new Alert("Conectar Erro: " ,  e.getClass() + " " + e.getMessage() + " " + e, 				null, AlertType.CONFIRMATION);            
            Web.display.setCurrent(al);;
        }
        return http;
    }
}

Sua aplicação necessita uma conexão HTTPS???
porque a URL que voce esta tentando chamar não é…

Nao.

Usando HttpConnection tambem nao funciona.

tevee algum progresso ai ?

Cara…faça um teste na sua aplicação chamando direto a url sem passar pela sua factory…


HttpConnection c = null;
DataInputStream in = null;
String resultado = "";
c = (HttpConnection)Connector.open("http://www.google.com.br");
c.setRequestMethod(HttpConnection.POST);

int length = (int) c.getLength();
byte[] bArr = new byte[length];
in.readFully(bArr);
resultado = new String(bArr);  // retorno