[英]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.