在firebase制作登入系统
可以使用myRef.child("member").get().addOnCompleteListener进入资料库里
task.getResult().getChildrenCount()可以侦测有几笔资料
使用
myRef.child("member").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
@Override
public void onComplete(@NonNull Task<DataSnapshot> task) {
Boolean ok = true;
long a =task.getResult().getChildrenCount();
if(account.getText().toString().matches("") || password.getText().toString().matches("")) {
Toast.makeText(login.this, "请输入帐号密码", Toast.LENGTH_SHORT).show();
}
else {
for (int i = 1; i <= a; i++) {
if (account.getText().toString().equals(task.getResult().child(String.valueOf(i)).child("account").getValue()) & password.getText().toString().equals(task.getResult().child(String.valueOf(i)).child("password").getValue())) {
ok = false;
SharedPreferences member_pref = getSharedPreferences("member", MODE_PRIVATE);
member_pref.edit().putString("USER", account.getText().toString())
.commit();
Intent intent = new Intent(login.this, MainActivity.class);
startActivity(intent);
}
}
if (ok){
Toast.makeText(login.this,"帐密错误",Toast.LENGTH_SHORT).show();
}
}
}
});
>>: Progressive Web App 取得 Geolocation API 地理资讯 (28)
a new born baby rest her head on the earth of mot...
MiniMap制作Part2 找到了tile生成时位置错乱的原因,还是因为进位造成的问题。A★内部是...
Python 对於程序初学者来说是最简单好学的语言了,他的优点有 语法简化而不复杂 强调程序码的可...
-通用标准评估 TCSEC 在 DoD 中用於评估受信任的计算机系统。它适用於整个计算机系统,而不...
Hello, 各位 iT邦帮忙 的粉丝们大家好~~~ 本篇是 Re: 从零开始用 Xamarin 技...