Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. package team3.teamproject;
  2.  
  3. import android.content.DialogInterface;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.os.StrictMode;
  7. import android.support.v7.app.AlertDialog;
  8. import android.support.v7.app.AppCompatActivity;
  9. import android.text.TextUtils;
  10. import android.util.Log;
  11. import android.view.View;
  12. import android.widget.EditText;
  13.  
  14. /**
  15. * Used for creating a new account
  16. * Created by Mantas Sutas
  17. */
  18. public class RegisterActivity extends AppCompatActivity {
  19.  
  20. EditText mUserName;
  21. EditText mPassword;
  22.  
  23.  
  24.  
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_register);
  29. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  30. StrictMode.setThreadPolicy(policy);
  31.  
  32.  
  33. mUserName = (EditText) findViewById(R.id.usernameText);
  34. mPassword = (EditText) findViewById(R.id.passwordText);
  35.  
  36.  
  37. }
  38.  
  39. public void onCreateAccountClick(View view) {
  40. String username = mUserName.getText().toString();
  41. String password = mPassword.getText().toString();
  42.  
  43. //In case the there is no response from the servers
  44. String response = "Something is wrong with the servers!";
  45.  
  46.  
  47. if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) {
  48. try {
  49. response = PostStreamReader.sendCreateString("createUser.php",
  50. "name=" + username
  51. + "&password=" + password);
  52.  
  53.  
  54. } catch (Exception e) {
  55. e.printStackTrace();
  56. }
  57.  
  58. //need to add alerts to notify user what's going on
  59. //also need to sort out serverside stuff
  60. Intent login = new Intent(this, LoginActivity.class);
  61. startActivity(login);
  62. //showAlertWindow("Registration was a success!");
  63. }
  64.  
  65.  
  66. }
  67.  
  68.  
  69.  
  70. // will complete later
  71. /** public void showAlertWindow(String message) {
  72. AlertDialog.Builder window = new AlertDialog.Builder(RegisterActivity.this);
  73. window.setMessage(message);
  74. window.setCancelable(false);
  75. window.setPositiveButton(
  76. "Ok", new DialogInterface.OnClickListener() {
  77. @Override
  78. public void onClick(DialogInterface dialogInterface, int i) {
  79.  
  80. startActivity(login);
  81. }
  82. }
  83. );
  84. window.create().show();
  85. }
  86. */
  87.  
  88. public void onGoBackClick(View view) {
  89. Intent goBack = new Intent(this, LoginActivity.class);
  90. startActivity(goBack);
  91. }
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement