Guest User

Untitled

a guest
Dec 11th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public class Login extends AppCompatActivity {
  2.  
  3. EditText usuario, senha;
  4. FrameLayout framePB;
  5.  
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.activity_login);
  10.  
  11. this.usuario = findViewById(R.id.edittextUsuario);
  12. this.senha = findViewById(R.id.edittextSenha);
  13. this.framePB = findViewById(R.id.framelayoutProgressBar);
  14. }
  15.  
  16. public void buttonLogin(View view) {
  17.  
  18. AsyncLogin login = new AsyncLogin(this.framePB, this.usuario.toString, this.senha.toString);
  19. login.execute();
  20. }
  21.  
  22. public class AsyncLogin extends AsyncTask<String, String, String> {
  23.  
  24. String usuario, senha;
  25. FrameLayout framePB;
  26.  
  27. public AsyncLogin(FrameLayout framePB, String usuario, String senha) {
  28.  
  29. this.framePB = framePB;
  30. this.usuario = usuario;
  31. this.senha = senha;
  32. }
  33.  
  34. ...
  35.  
  36. }
  37.  
  38. public class Login extends AppCompatActivity {
  39.  
  40. public void buttonLogin(View view) {
  41.  
  42. String retorno = "";
  43.  
  44. AsyncLogin login = new AsyncLogin(this.framePB, this.usuario.toString, this.senha.toString);
  45. login.execute();
  46.  
  47. try {
  48. retorno = login.get();
  49. } catch (InterruptedException e) {
  50. e.printStackTrace();
  51. } catch (ExecutionException e) {
  52. e.printStackTrace();
  53. }
  54.  
  55. Toast.makeText(this, retorno, Toast.LENGTH_SHORT).show();
  56. }
  57.  
  58. }
Add Comment
Please, Sign In to add comment