Advertisement
goldenegg56

Untitled

Apr 25th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. protected String doInBackground(String[] arg0)
  2. {
  3. EditText et = (EditText) findViewById(R.id.email);
  4. String str = et.getText().toString();
  5.  
  6. EditText et2 = (EditText) findViewById(R.id.Password);
  7. String str2 = et2.getText().toString();
  8.  
  9. try{
  10. BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
  11. Socket clientSocket = new Socket("192.168.0.5", 6789);
  12. DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
  13. BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
  14. usrname = et.getText().toString();
  15. Log.w("app", "1");
  16. outToServer.writeBytes(str + " " + str2 + '\n');
  17. Log.w("app", "2");
  18. modifiedSentence = inFromServer.readLine();
  19. Log.w("app", "3");
  20. Log.w("app", "FROMSERVER: " + modifiedSentence);
  21. if(modifiedSentence.equals("1")){
  22. Intent i = new Intent(Login.this, Control_Panel.class);
  23. startActivity(i);
  24. }else if(modifiedSentence.equals("2")){
  25. message();
  26.  
  27. text.setText("The password/username is incorrect");
  28. }
  29. clientSocket.close();
  30.  
  31.  
  32. } catch (IOException e) {
  33. Log.w("app", e.toString());
  34. return "Error";
  35. }
  36.  
  37. return modifiedSentence;
  38.  
  39. }
  40.  
  41. protected void onPostExecute(String result)
  42. {
  43. Log.w("app", result);
  44.  
  45.  
  46. }
  47.  
  48. }
  49.  
  50. void message(String[] args){
  51. text = (TextView) findViewById(R.id.incorrect);
  52. text.setText("The password/username is incorrect");
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement