void login() {
try {
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http://119.70.20.234/ttest2.php");
nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", inputID.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("password", inputPW.getText().toString()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = httpclient.execute(httppost);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final String response = httpclient.execute(httppost, responseHandler);
System.out.println("Response : " + response);
runOnUiThread(new Runnable() {
@Override
public void run() {
tv.setText("Response from PHP : " + response);
dialog.dismiss();
}
});
if (response.equalsIgnoreCase("success")) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// final Toast toast=Toast.makeText(MainActivity.this, "Login Success", Toast.LENGTH_SHORT);
// toast.show();
startActivity((new Intent(MainActivity.this, MenuPage.class)));
finish();
// Intent intent=new Intent(MainActivity.this,MenuPage.class);
// startActivity(intent);
}
});
// startActivity((new Intent(MainActivity.this, MenuPage.class)));
// finish();
} else {
// Toast.makeText(MainActivity.this, "Login Fail", Toast.LENGTH_SHORT).show();
// Intent intent=new Intent(MainActivity.this,FailPage.class);
// startActivity(intent);
}
}
catch(Exception e)
{
dialog.dismiss();
System.out.println("Exception : " + e.getMessage());
}
}
php 서버에서 셀렉트 성공시 success 를 보내거나 fail 을 echo 하는것까지는 되는데요, success일 경우 인텐트가 되질 않습니다. 오류는 없는데 뭐가 문제인지 모르겠습니다.
정리하면 mysql 에 저장된 아이디와 비밀번호는 일치하면 success를 echo 하는 것 까지는 되는데 쓰레드안에서 intent 가 되질 않습니다.