简体   繁体   English

如何创建 firebase 用户帐户

[英]How can I create firebase user account

I'm successfully created user with email from android without any problem but after I downloaded the standard java library and tried to make user I get no error or feedback for error or success in callback我成功地使用 email 从 android 创建了用户,没有任何问题,但是在我下载了标准的 java 库并尝试让用户我没有收到任何错误或错误反馈或回调成功

public static void main(String ...args){
    String url= "https://example.firebaseio.com/";
    Firebase fb = new Firebase(url);
    fb.createUser("example@gmail.com", "123456", new Firebase.ResultHandler() {
        @Override
        public void onSuccess() {
            System.out.println("success");
        }
        @Override
        public void onError(FirebaseError firebaseError) {
            System.out.println("failed !");
        }
    });
    System.out.println("Hello there");
}

as above comments , the problem is the main thread is exit before ResultHnadler get called so i fixed the problem in this way to prevent the main thread terminate before the ResultHnadler get called its nice if there is better way 如上面的注释,问题是主要的线程是在ResultHnadler被调用之前退出所以我用这种方式修复了问题,以防止主线程在ResultHnadler被调用之前终止,如果有更好的方法

 public static void main(String ...args)  {
    final AtomicBoolean isCalled = new AtomicBoolean(false);
    String FIREBASE = "https://example.firebaseio.com/";
    Firebase fb = new Firebase(FIREBASE);
    fb.createUser("testtesttest@gmail.com", "1234321", new Firebase.ResultHandler() {
        @Override
        public void onSuccess() {
            isCalled.set(true);
            System.out.println("success");
        }
        @Override
        public void onError(FirebaseError firebaseError) {

            isCalled.set(true);
            System.out.println("fail");
        }
    });
    while (!isCalled.get()){
    }
}

If u are using an emulator to run your code just wait for 20-30 minutes,Because nowadays takes that much time,else you can use a device:it is much faster如果您使用模拟器运行您的代码,只需等待 20-30 分钟,因为现在需要那么多时间,否则您可以使用设备:它快得多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows上使用其他用户帐户创建新进程? - How can I create a new process with another User Account on Windows? 如何在我的Android应用程序中使用firebase-ui时,用户是否已经创建了一个帐户? - How can I know if a user already created an account while using firebase-ui on my android application? 如何从 Firebase 的列表视图中的管理员帐户中删除用户帐户? - How to delete user account from admin account in listview in Firebase? 如何使用java创建Facebook帐户 - How can i create a facebook account using java 如何在JAVA中为帐户确认邮件创建Web令牌 - How can I create a web token for account confirmation mail in JAVA 将 Intellij 许可证用户帐户更改为新帐户后,如何恢复 maven 依赖问题? - How can I recover maven dependency issues after changing my Intellij license user account to a new account? 如何为SFTP(Java)创建帐户或用户? - How create account or user for SFTP (Java) ? 如何使用用户输入创建银行帐户? - How to create a bank account with user input? 我怎样才能收到正确的 url? 尝试从 firebase 应用程序中的 googlesignin 帐户获取个人资料图片 - How can I receive the correct url ? Trying to get the profile picture from the googlesignin account in firebase app 我如何指向随机密钥(firebase用户ID) - how can i point to the random key( firebase user ID)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM