當前位置: 首頁>>代碼示例>>Java>>正文


Java AuthResult類代碼示例

本文整理匯總了Java中com.google.firebase.auth.AuthResult的典型用法代碼示例。如果您正苦於以下問題:Java AuthResult類的具體用法?Java AuthResult怎麽用?Java AuthResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AuthResult類屬於com.google.firebase.auth包,在下文中一共展示了AuthResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performFirebaseRegistration

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
@Override
public void performFirebaseRegistration(Activity activity, final String email, String password) {
    FirebaseAuth.getInstance()
            .createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.e(TAG, "performFirebaseRegistration:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        mOnRegistrationListener.onFailure(task.getException().getMessage());
                    } else {
                        // Add the user to users table.
                        /*DatabaseReference database= FirebaseDatabase.getInstance().getReference();
                        User user = new User(task.getResult().getUser().getUid(), email);
                        database.child("users").push().setValue(user);*/

                        mOnRegistrationListener.onSuccess(task.getResult().getUser());
                    }
                }
            });
}
 
開發者ID:mustafaozhan,項目名稱:Howl,代碼行數:26,代碼來源:RegisterInteractor.java

示例2: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    LogUtil.logDebug(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    showProgress();

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    LogUtil.logDebug(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        handleAuthError(task);
                    }
                }
            });
}
 
開發者ID:rozdoum,項目名稱:social-app-android,代碼行數:21,代碼來源:LoginActivity.java

示例3: handleFacebookAccessToken

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);
    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
 
開發者ID:Shobhit-pandey,項目名稱:CollegeDoc,代碼行數:20,代碼來源:MainActivity.java

示例4: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
@Override
public void firebaseAuthWithGoogle(GoogleSignInAccount account,
                                   final Callbacks.IResultCallback<Usuario> callback) {
    showLog("firebaseAuthWithGoogle: " + account.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
    FirebaseAuth.getInstance()
            .signInWithCredential(credential)
            .addOnFailureListener( reportError(callback))
            .addOnSuccessListener(new OnSuccessListener<AuthResult>() {
                @Override
                public void onSuccess(AuthResult authResult) {
                    FirebaseUser user = authResult.getUser();
                    loginFlow( user, callback);
                }
            });
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:17,代碼來源:UserRemoteDataSource.java

示例5: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    MyLg.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()+" "+acct.getPhotoUrl());
    showProgressDialog();

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    MyLg.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        MyLg.w(TAG, "signInWithCredential");
                        Toas.show(context, "Authentication failed.");
                    }
                    hideProgressDialog();
                }
            });
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:23,代碼來源:SignInBaseActivity.java

示例6: handleFacebookAccessToken

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void handleFacebookAccessToken(AccessToken token) {
    LogUtil.logDebug(TAG, "handleFacebookAccessToken:" + token);
    showProgress();

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    LogUtil.logDebug(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        handleAuthError(task);
                    }
                }
            });
}
 
開發者ID:rozdoum,項目名稱:social-app-android,代碼行數:21,代碼來源:LoginActivity.java

示例7: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(SignInActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    } else {
                        startActivity(new Intent(SignInActivity.this, MainActivity.class));
                        finish();
                    }
                }
            });
}
 
開發者ID:YoWenqin,項目名稱:BuddiesGo,代碼行數:24,代碼來源:SignInActivity.java

示例8: startSession

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
protected void startSession() {
    Log.i("scan.log", "Init database session" );
    final ScannerDao scannerDao = new ScannerDao( this.context );

    this.auth = FirebaseAuth.getInstance();
    FirebaseUser currentUser = this.auth.getCurrentUser();
    if( currentUser == null ) {
        Log.i("scan.log", "No Has User connerct" );
        this.auth.signInWithEmailAndPassword( "[email protected]", "123456" )
                .addOnCompleteListener( new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if( task.isSuccessful() ) {
                            initDataBase( scannerDao );
                        }
                    }
                });
    } else {
        Log.i("scan.log", "Has user connected" );
        this.initDataBase( scannerDao );
    }
}
 
開發者ID:tec-ustp,項目名稱:SIIEScanner,代碼行數:23,代碼來源:FirebaseScanner.java

示例9: setUp

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers
            .DIGITS_CONSUMER_KEY_KEY))).thenReturn(DIGITS_CONSUMER_KEY);
    when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers
            .DIGITS_CONSUMER_SECRET_KEY))).thenReturn(DIGITS_CONSUMER_SECRET);
    when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers
            .FABRIC_API_KEY_KEY))).thenReturn(FABRIC_API_KEY);
    authResult = new AuthResult() {
        @Override
        public FirebaseUser getUser() {
            return mockFirebaseUser;
        }

        @Override
        public AdditionalUserInfo getAdditionalUserInfo() {
            return null;
        }
    };

    authResultTask = Tasks.forResult(authResult);
}
 
開發者ID:firebase,項目名稱:digits-migration-helper-android,代碼行數:24,代碼來源:AuthMigratorTest.java

示例10: signIn

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void signIn(String email, String password) {
    Log.d(TAG, "signIn:" + email);
    mAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithEmail:success");
                        FirebaseUser user = mAuth.getCurrentUser();

                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithEmail:failure", task.getException());
                    }
                }
            });
}
 
開發者ID:tpakis,項目名稱:Charities,代碼行數:19,代碼來源:ListWishesActivity.java

示例11: authWithGithub

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void authWithGithub() {
    FirebaseAuth mAuth = FirebaseAuth.getInstance();

    // [START auth_with_github]
    String token = "<GITHUB-ACCESS-TOKEN>";
    AuthCredential credential = GithubAuthProvider.getCredential(token);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }
            });
    // [END auth_with_github]
}
 
開發者ID:firebase,項目名稱:snippets-android,代碼行數:27,代碼來源:MainActivity.java

示例12: onComplete

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
    if (task.isSuccessful()) {
        FirebaseAuth firebaseAuth = SessionManager.getFirebaseAuth();
        FirebaseUser currentUser = SessionManager.getFirebaseUser();

        boolean isEmailVerified = currentUser.isEmailVerified();
        // TODO zmienić z powrotem
        if (true) {
            updateLoginConfigInSharedPrefs();

            SessionManager.initializeCurrentUserFirebaseListeners();
            SessionManager.initializeFamilyMembersFirebaseListener();

            Intent intent = new Intent(context, MainActivity.class);
            context.startActivity(intent);
        } else {
            firebaseAuth.signOut();
            Toast.makeText(context, R.string.email_not_verified, Toast.LENGTH_LONG).show();
        }
    } else {
        logger.logWarn("Sign In Failure: " + task.getException());
        Toast.makeText(context, R.string.invalid_email_or_password, Toast.LENGTH_LONG).show();
    }
}
 
開發者ID:lmnpWmi,項目名稱:wirtualnaApteczka,代碼行數:26,代碼來源:LogInOnCompleteListener.java

示例13: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount account) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId());
    showProgressDialog();
    AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
                    hideProgressDialog();
                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(AuthActivity.this, R.string.auth_failed,
                                Toast.LENGTH_SHORT).show();
                    }
                    // ...
                }
            });
}
 
開發者ID:braulio94,項目名稱:Quadro,代碼行數:23,代碼來源:AuthActivity.java

示例14: handleTwitterSession

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
private void handleTwitterSession(TwitterSession session) {
	Utils.d("Twitter:HandleSession:" + session);

	AuthCredential credential = TwitterAuthProvider.getCredential(
	session.getAuthToken().token,
	session.getAuthToken().secret);

	mAuth.signInWithCredential(credential)
	.addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
		@Override
		public void onComplete(@NonNull Task<AuthResult> task) {
			if (task.isSuccessful()) {
				// Sign in success, update UI with the signed-in user's information
				Utils.d("signInWithCredential:success");
			} else {
				// If sign in fails, display a message to the user.
				Utils.w("signInWithCredential:failure: " + task.getException());
			}

			// ...
		}
	});
}
 
開發者ID:FrogSquare,項目名稱:GodotFireBase,代碼行數:24,代碼來源:TwitterSignIn.java

示例15: createAccount

import com.google.firebase.auth.AuthResult; //導入依賴的package包/類
public void createAccount(final String email, final String password) {
	Utils.d("E&P:CreateAccount:" + email);

	mAuth.createUserWithEmailAndPassword(email, password)
	.addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
		@Override
		public void onComplete(@NonNull Task<AuthResult> task) {
			Utils.d("E&P:CreateUserWithEmail:onComplete:" + task.isSuccessful());

			// If sign in fails, display a message to the user. If sign in succeeds
			// the auth state listener will be notified and logic to handle the
			// signed in user can be handled in the listener.

			if (!task.isSuccessful()) {
				Utils.d("E&P:CreateAccount:Error");
			}
		}
	});
}
 
開發者ID:FrogSquare,項目名稱:GodotFireBase,代碼行數:20,代碼來源:EmailAndPassword.java


注:本文中的com.google.firebase.auth.AuthResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。