Connexion à distance
sousou
-
sousou -
sousou -
Bonsoir
je suis débutant en android , j'essaie de faire un connection à distance de mon aplication android avec une base des données dans mon pc , je reussi de le faire avec emilator , mais il n'executer pas dans mon portable ,meme si dans le meme resaux
et voila mon code (je change l'@ ip 10.0.2.2 par mon @ip)
s'il vous plait m'aider
et merci
je suis débutant en android , j'essaie de faire un connection à distance de mon aplication android avec une base des données dans mon pc , je reussi de le faire avec emilator , mais il n'executer pas dans mon portable ,meme si dans le meme resaux
et voila mon code (je change l'@ ip 10.0.2.2 par mon @ip)
private static final String strURL = "http://10.0.2.2:80/webservice/parent.php"; private JSONArray jArray; private JSONObject json_data; ...... String result =null; InputStream is = null; StringBuilder sb = new StringBuilder(); ArrayList<NameValuePair> nameValuePairs=new ArrayList<NameValuePair> (); nameValuePairs.add(new BasicNameValuePair("iden",cin.getText().toString())); try{ HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(strURL); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); }catch(Exception e){ Log.e("log_tag", "Error in http connection " + e.toString()); } try{ BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result=sb.toString(); }catch(Exception e){ Log.e("log_tag", "Error in http connection " + e.toString()); } String essai=result.substring(0, 4) ; try { if (result.matches("<br >")){ essai=result.substring(0, 2) ; } JSONArray jArray = new JSONArray(result); JSONObject json_data = jArray.getJSONObject(0); String nomm =json_data.getString("nom").toString(); if (nomm.equals(nom.getText().toString()) ){ Intent intent =new Intent(MainActivity.this,choisir_eleve.class); intent.putExtra(EXTRA_PARENT,cin.getText().toString()); intent.putExtra(EXTRA_CINPARENT,nom.getText().toString()); startActivity(intent); } else { Toast.makeText(MainActivity.this, "nom n'exist pas", Toast.LENGTH_LONG).show(); } }catch(JSONException e){ Toast.makeText(MainActivity.this, "Verifier cin ", Toast.LENGTH_LONG).show(); }
s'il vous plait m'aider
et merci
A voir également:
- Connexion à distance
- Gmail connexion - Guide
- Allumer pc à distance - Guide
- Connexion chromecast - Guide
- Gmail connexion autre compte - Guide
- Site inaccessible n'autorise pas la connexion - Guide