Android - Problemas al conectar Android con PHP

 
Vista:

Problemas al conectar Android con PHP

Publicado por Marc Valdivia (1 intervención) el 02/09/2013 10:50:54
Hola a todos,

Este es mi primer post en el foro y en cualquier otro sobre programación, espero que puedan ayudarme.
Estoy desarrollando una app para Android que tiene una base de datos en MySql. En un principio el código esta bien ya que el emulador funciona tal y como yo quiero, el problema viene al quererlo pasar a mi Smartphone, donde me devuelve un String de error. Alguien sabe que puede ocurrir.

Código de Conexión:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public class ComprobarPartida {
 
public String Comprobarpartida (String urlComprobarPartida, String nombre_partida){
 
try {
 
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(urlComprobarPartida);
 
//AÑADIR PARÁMETROS
List <NameValuePair> datos = new ArrayList <NameValuePair>();
datos.add(new BasicNameValuePair("nombre_partida",nombre_partida));
httppost.setEntity(new UrlEncodedFormEntity(datos));
 
HttpResponse httpcrearpartida = httpclient.execute(httppost);
HttpEntity EntityCrearPartida = httpcrearpartida.getEntity();
 
String resultadocrearpartida = EntityUtils.toString(EntityCrearPartida);
return resultadocrearpartida;
 
} catch (Exception e) {
return "error";
}
 
}
 
}

Código en Activity Android:
1
2
3
4
5
6
7
8
9
case R.id.btncomprovarpartida:
nombre_partida = etnombrepartida.getText().toString();
ComprobarPartida cp = new ComprobarPartida();
disponible = cp.Comprobarpartida("enlace", nombre_partida);
txtdisponible.setText(disponible);
if (disponible.equals("Nombre Disponible")) {
desAllEnabled();
}
break;
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Problemas al conectar Android con PHP

Publicado por Andrés (1 intervención) el 18/10/2013 14:04:19
R.id.btncomprovarpartida
cp.Comprobarpartida
ahí esta el error
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar