public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText login_id = (EditText)findViewById(R.id.user_ID), login_pw = (EditText)findViewById(R.id.user_PW);
Button login_bt = (Button)findViewById(R.id.login), Regiser_bt = (Button)findViewById(R.id.Regiser);
Regiser_bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent Register = new Intent(MainActivity.this,RegisterActivity.class);
startActivity(Register);
}
});
login_bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (login_id.getText().toString().length() == 0){
Toast.makeText(MainActivity.this, "아이디 를 입력해주세요.",Toast.LENGTH_SHORT).show();
return;
}
if (login_pw.getText().toString().length() == 0){
Toast.makeText(MainActivity.this, "비밀번호 를 입력해주세요.",Toast.LENGTH_SHORT).show();
return;
}
String user_ID = login_id.getText().toString();
String user_PW = login_pw.getText().toString();
Response.Listener<String> responselistener = new Response.Listener<String>() {
@Override
public void onResponse(final String response) {
try{
JSONObject jsonReponse = new JSONObject(response);
boolean success = jsonReponse.getBoolean("success");
if (success){
Intent intent = new Intent(MainActivity.this, WebView.class);
startActivity(intent);
}else {
new android.app.AlertDialog.Builder(MainActivity.this)
.setTitle("알림")
.setMessage("로그인 실패.")
.setNeutralButton("다시 시도", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
return;
}
})
.setCancelable(false)
.create()
.show();
}
}catch (Exception e){
e.printStackTrace();
}
}
};
LoginRequest loginRequest = new LoginRequest(user_ID, user_PW, responselistener);
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
queue.add(loginRequest);
}
});
}
}
이게 전체 코드구요 아래가 로그인 버튼 클릭시 나오는 로그입니다.
W/System.err: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.loginactivity/android.webkit.WebView}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1939)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1617)
at android.app.Activity.startActivityForResult(Activity.java:4477)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4435)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at android.app.Activity.startActivity(Activity.java:4796)
W/System.err: at android.app.Activity.startActivity(Activity.java:4764)
at com.example.loginactivity.MainActivity$2$1.onResponse(MainActivity.java:61)
at com.example.loginactivity.MainActivity$2$1.onResponse(MainActivity.java:53)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:82)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:29)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:102)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770