package com.example.administrator.yewsss;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Looper;
import android.os.StrictMode;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.util.ArrayList;
import java.util.List;
public class JoinActivity extends ActionBarActivity {
Button JoinBtn,LoginBtn1;
EditText edtId,edtPw,edtName,edtMail;
HttpPost httppost;
HttpResponse response;
HttpClient httpclient;
List<NameValuePair> nameValuePairs;
ProgressDialog dialog = null;
private static final String SERVER_ADDRESS = "http://아이피주소";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_join);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
edtId=(EditText)findViewById(R.id.edtId);
edtPw =(EditText)findViewById(R.id.edtPw);
edtName=(EditText)findViewById(R.id.edtName);
edtMail=(EditText)findViewById(R.id.edtMail);
JoinBtn =(Button)findViewById(R.id.JoinBtn);
LoginBtn1=(Button)findViewById(R.id.LoginBtn1);
JoinBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (edtId.getText().toString().equals("") || edtPw.getText().toString().equals("") || edtName.getText().toString().equals("") || edtMail.getText().toString().equals("")) {
Toast.makeText(JoinActivity.this, "입력오류입니다", Toast.LENGTH_SHORT).show();
return;
}//항목중 하나라도 입력이 안되었을때
dialog = ProgressDialog.show(JoinActivity.this, "",
"이런 ..", true);
new Thread(new Runnable() {
public void run() {
Looper.prepare();
join();
Looper.loop();
}
}).start();
}
});
}
void join(){
try{
httpclient=new DefaultHttpClient();
httppost= new HttpPost("http://아이피주소/PHP파일경로/ex1.php");//"C:/APM_Setup/htdocs/web_server/lostdog";
nameValuePairs = new ArrayList<NameValuePair>(4);
nameValuePairs.add(new BasicNameValuePair("Id",edtId.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("Pw",edtPw.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("Name",edtName.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("Mail",edtMail.getText().toString()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response=httpclient.execute(httppost);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final String response = httpclient.execute(httppost, responseHandler);
runOnUiThread(new Runnable() {
public void run() {
dialog.dismiss();
}
});
Toast.makeText(JoinActivity.this, "WELCOME", Toast.LENGTH_SHORT).show();
/* Intent iIntent = new Intent(JoinActivity.this, LoginActivity.class);
startActivity(iIntent);
finish();*/
}catch(Exception e){
dialog.dismiss();
System.out.println("Exception : " + e.getMessage());
}
}
}
안녕하세요
안드로이드를 배운지 얼마 안되 학생입니다
회원가입을 만들어봤는데요 ㅜ.ㅜ
회원가입버튼을 누르면 화면이 멈춥니다
물론 디비에도 데이터가 안들어가구요 ..
뭐가 문제일까요 ㅜ.ㅜ
부탁드립니다!!ㅜ.ㅜ