我是Android應用程序開發(fā)的新手,我需要兩個文本框用戶名和密碼,它將登錄到服務器并使用php頁面與數(shù)據(jù)庫進行檢查,如果登錄成功,則轉(zhuǎn)到下一個屏幕,否則顯示一個msg框顯示登錄錯誤我該怎么辦?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()); }}
- 2 回答
- 0 關(guān)注
- 564 瀏覽
添加回答
舉報
0/150
提交
取消