此信息是“金额”,它是用户特定的。 我的登录代码是
public class UserLoginActivity extends AppCompatActivity {
EditText myNumber, Pin;
Button LogIn ;
String PinHolder, NumberHolder;
String finalResult ;
String HttpURL = "https://[my site].[myhost].com/User/UserLogin.php";
Boolean CheckEditText ;
ProgressDialog progressDialog;
HashMap<String,String> hashMap = new HashMap<>();
HttpParse httpParse = new HttpParse();
public static final String UserNumber = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_login);
myNumber = (EditText)findViewById(R.id.myNumber);
Pin = (EditText)findViewById(R.id.editTextPin);
LogIn = (Button)findViewById(R.id.Login);
LogIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CheckEditTextIsEmptyOrNot();
if(CheckEditText){
UserLoginFunction(NumberHolder, PinHolder);
}
else {
Toast.makeText(UserLoginActivity.this, "Please fill all form fields.", Toast.LENGTH_LONG).show();
}
}
});
}
public void CheckEditTextIsEmptyOrNot(){
NumberHolder = myNumber.getText().toString();
PinHolder = Pin.getText().toString();
if(TextUtils.isEmpty(NumberHolder) || TextUtils.isEmpty(PinHolder))
{
CheckEditText = false;
}
else {
CheckEditText = true ;
}
}
public void UserLoginFunction(final String number, final String pin){
class UserLoginClass extends AsyncTask<String,Void,String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(UserLoginActivity.this,"Loading Data","it takes a sec..",true,true);
}
@Override
protected void onPostExecute(String httpResponseMsg) {
super.onPostExecute(httpResponseMsg);
progressDialog.dismiss();
if(httpResponseMsg.equalsIgnoreCase("Data Matched")){
finish();
Intent intent = new Intent(UserLoginActivity.this, DashboardActivity.class);
intent.putExtra(UserNumber,number);
startActivity(intent);
}
else{
Toast.makeText(UserLoginActivity.this,httpResponseMsg,Toast.LENGTH_LONG).show();
}
}
@Override
protected String doInBackground(String... params) {
hashMap.put("number",params[0]);
hashMap.put("pin",params[1]);
finalResult = httpParse.postRequest(hashMap, HttpURL);
return finalResult;
}
}
UserLoginClass userLoginClass = new UserLoginClass();
userLoginClass.execute(number,pin);
}
我的仪表板代码是
// Http Url For Filter Accounts Data from Id Sent from previous activity.
String HttpURL = "https://[my site].[myhost].com/User/FilterAccountsData.php";
Button LogOut, SendMoney, History, MainAcc;
TextView NameShow, NumberShow, BalShow;
String NameHolder, NumberHolder, BalHolder, JerryCurls;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
//called and labelled my buttons and textviews here.
Intent intent = getIntent();
JerryCurls = intent.getStringExtra(UserLoginActivity.UserNumber);
//Receiving the ListView Clicked item value send by previous activity.
JerryCurls = getIntent().getStringExtra("UserNumber");
//Calling method to filter Student Record and open selected record.
//HttpWebCall(JerryCurls);
//NumberShow.setText(NameHolder);
LogOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
Intent intent = new Intent(DashboardActivity.this, UserLoginActivity.class);
startActivity(intent);
Toast.makeText(DashboardActivity.this, "Log Out Successfully", Toast.LENGTH_LONG).show();
}
});
SendMoney.setOnClickListener(new View.OnClickListener() {
...
Toast.makeText(DashboardActivity.this, "Verify Account Before Sending", Toast.LENGTH_LONG).show();
}
});
MainAcc.setOnClickListener(new View.OnClickListener() {
...
Toast.makeText(DashboardActivity.this, " Ha! This is not tools..", Toast.LENGTH_LONG).show();
}
});
History.setOnClickListener(new View.OnClickListener() {
...
}
});
}
protected void onPostExecute(Void result)
{
// Setting Student Name, Phone Number, Class into TextView after done all process .
NameShow.setText(NameHolder);
NumberShow.setText(NumberHolder);
BalShow.setText(BalHolder);
}
}
this is the DB and the 'balance' is what am trying to show for the user on his dashboard.
我觉得我的代码非常不安全,没有完全关闭。请多多包涵.. 好紧张。 找不到任何解决此问题的教程,这真的使我感到沮丧和沮丧。 有人帮助我,任何人,每个人。 仍在尝试学习android ..提前祝福你..