Android'de bir HTTP Post yapmak nasıl?

0 Cevap php

giriş başarının ardından bir msg kutusunu göstermek başka sonraki ekrana giderseniz ben android uygulama geliştirme için yeni, ne gerek ben iki metin kutusu adı ve şifresine sahip olup, bu sunucuya göndermek ve bir php sayfasını kullanarak DB ile kontrol edecek giriş hata gösteren ben bunu nasıl yapabilirim?

public void postData() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://google.com");
    EditText tw =(EditText) findViewById(R.id.EditText01);
    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("id", "12345"));
        nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);
        int status = response.getStatusLine().getStatusCode();

        tw.setText(status);
    } catch (ClientProtocolException e) {
        tw.setText(e.toString());
    } catch (IOException e) {
        tw.setText(e.toString());
    }
} 

0 Cevap