企划实现(26)

在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();
                    }
                }
            }
        });

<<:  Day30 - Intent传讯息

>>:  企划实现(26)

创建App-联络客服

创建App-联络客服 由於本App的联络客服功能的延伸界面使用最简介的方式来设计,因为本App的原始...

win破解後可以接着使用商业的大量授权吗

各位大大们 你好 小弟想询问一下,因为使用大量授权好像前面都需要先安装过win授权,像是随机版之类的...

D26 / 要怎麽放 Compose 进我的专案? - Compose View

今天大概会聊到的范围 ComposeView 之前有介绍过 Compose 中的 AndroidV...

Day11 ATT&CK for ICS - Initial Access(1)

Initial Access 针对初始访问阶段,恶意攻击者会利用各种方法进入工控场域,因此 Ini...