1
I have a little app of chat who logs in and sends messages to the server through php + JSON, but each query crashes the app for a half second, which is really boring.
I heard something called Backgroundworker, but I don’t know exactly how it works.
This is my code:
EditText campoLogin = (EditText)findViewById(R.id.campo_de_login);
EditText campoSenha = (EditText)findViewById(R.id.campo_de_senha);
Conectar Conn = new Conectar("http://meusite.com/chat/login.php?login=" + campoLogin.getText() + "&senha=" + campoSenha.getText() );
JSONArray array = new JSONArray(Conn.response);
JSONObject object = array.getJSONObject(0);
id = (String) object.get("id");
nome = (String) object.get("nome");
It would need to make this process not crash, and work in the background...
What stops android query, php or java?
– Jorge B.
Android consults a php page that the same query the BD and is received on Android. Works well, but hangs.
– Dannark
Where does Voce have the server? Does it have a good network connection? What about android? I send XML files and it’s relatively fast. It crashes or takes time?
– Jorge B.
The server is Pretty Fast the problem is that the app hangs when connecting until receiving the message, that is if I make a loop that updates all the time making several connections then the app would crash without stopping.....
– Dannark
Ah that, you have to put your service on android as a service.
– Jorge B.