Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public void doLogin(View v) {
  2. String userid = ((EditText) findViewById(R.id.editText)).getText().toString();
  3. String password = ((EditText) findViewById(R.id.editText2)).getText().toString();
  4. doAut(v, userid, password);
  5. }
  6.  
  7. public void doAut(View v, String userid, String password){
  8.  
  9. BufferedReader reader = null;
  10. StringBuilder stringBuilder;
  11.  
  12. try{
  13. URL url = new URL("http://60.51.18.179/kjiisprod/module/test/simbllogin.php?uid=" + userid +"&pwd="+ password);
  14.  
  15. HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  16. urlConnection.setRequestMethod("GET");
  17.  
  18. reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
  19. stringBuilder = new StringBuilder();
  20.  
  21. String line = reader.readLine().toString();
  22.  
  23. stringBuilder.append(line.trim());
  24.  
  25. if(stringBuilder.toString().equals("1")){
  26. Intent i = new Intent(this, WelcomeActivity.class);
  27. startActivity(i);
  28. }else{
  29. Toast.makeText(this, "Login Error!. Try again." , Toast.LENGTH_LONG ).show();
  30. }
  31.  
  32.  
  33. }catch (Exception e){
  34. e.printStackTrace();
  35. StringWriter sw = new StringWriter();
  36. e.printStackTrace(new PrintWriter(sw));
  37. String exceptionAsString = sw.toString();
  38. Toast.makeText(this, exceptionAsString , Toast.LENGTH_LONG).show();
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement