public class MainActivity extends AppCompatActivity {
LoginBackgroundTask backgroundTask;
static String ID;
static String PW;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void click_regist(View v)
{
Intent it= new Intent(getApplicationContext(),regist.class);
startActivity(it);
}
public void click_login(View v) throws ExecutionException, InterruptedException {
EditText ido=(EditText)findViewById(R.id.idtext);
EditText pwo=(EditText)findViewById(R.id.pwtext);
ID=ido.getText().toString();
PW=pwo.getText().toString();
backgroundTask =new LoginBackgroundTask();
Object aa= backgroundTask.execute(new String[]{ID,PW}).get().toString();
TextView tv=(TextView)findViewById(R.id.textView9);
tv.setText(aa.toString());
if(Integer.parseInt(aa.toString())==0)
{
Toast.makeText(this, "로그인 오류!", Toast.LENGTH_SHORT).show();
}
else if(Integer.parseInt(aa.toString())==1)
{
Intent stu= new Intent(getApplicationContext(),Student.class);
startActivity(stu);
}
else if(Integer.parseInt(aa.toString())==2)
{
Intent tea= new Intent(getApplicationContext(),Teacher.class);
startActivity(tea);
}
else if(Integer.parseInt(aa.toString())==3)
{
Intent stu= new Intent(getApplicationContext(),Student.class);
startActivity(stu);
}
else
{
Toast.makeText(this,"안되",Toast.LENGTH_SHORT).show();
}
}
public class LoginBackgroundTask extends AsyncTask<String,Integer,Object>
{
protected void onPostExecute(String result)
{
}
@Override
protected Object doInBackground(String...params)
{
SoapObject request = new SoapObject("http://tempuri.org/","Login"); // 네임스페이스 메소드 이름
request.addProperty("user_id",params[0]); //로그인시 전달할 아이디
request.addProperty("pw",params[1]); //로그인시 전달할 비번
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.setOutputSoapObject(request);
envelope.dotNet=true;
envelope.encodingStyle = SoapEnvelope.ENC;
envelope.implicitTypes = false;
HttpTransportSE androidHttpTransport=new HttpTransportSE("http://192.168.33.46:11000/Service"); //url
androidHttpTransport.debug=true;
Object result=4;
try {
androidHttpTransport.call("http://tempuri.org/IService/Login",envelope); //soap의 액션
result=envelope.getResponse();
}
catch (Exception e)
{
e.getStackTrace();
}
return result;
}
}
}
200번만 예외에서 제외하는데
202번도 예외에서 제외 안시킬수 없나요