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
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.