-
Notifications
You must be signed in to change notification settings - Fork 0
/
Register.java
108 lines (73 loc) · 2.63 KB
/
Register.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.d_andaman;
import com.d_andaman.R;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@SuppressLint("NewApi")
public class Register extends Activity{
private Button register;
private Button login;
private EditText name;
private EditText user;
private EditText password;
private ProgressDialog pDialog;
private TextView status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
ActionBar action = getActionBar();
action.setIcon(R.drawable.meanu_bar);
action.setTitle("Register");
name = (EditText) findViewById(R.id.name);
user = (EditText) findViewById(R.id.username);
password=(EditText)findViewById(R.id.password);
login = (Button) findViewById(R.id.btnLinkToLoginScreen);
register = (Button) findViewById(R.id.btnRegister);
status = (TextView) findViewById(R.id.regst);
pDialog = new ProgressDialog(this);
pDialog.setCancelable(false);
register.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String f_name = name.getText().toString().trim();
String f_user = user.getText().toString().trim();
String f_password=password.getText().toString().trim();
if (!f_name.isEmpty() && !f_user.isEmpty()&&!f_password.isEmpty()) {
register_api(f_name,f_user,f_password);
} else {
// Prompt user to enter credentials
Toast.makeText(getApplicationContext(),
"Please enter the credentials!", Toast.LENGTH_SHORT).show();
}
} });
login.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),
MainActivity.class);
startActivity(i);
finish();
} });
}
public void register_api(String name,String user,String password){
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
new Reg_user(this,status,1).execute(name,user,password);
}else{
status.setText("No network connection available.");}
}
}