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


Java FirebaseUser類代碼示例

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


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

示例1: onCreateView

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_journal_list, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
        FirebaseAuth auth = FirebaseAuth.getInstance();
        FirebaseUser user = auth.getCurrentUser();
        DatabaseReference userRef = dbRef.getReference(user.getUid());
        userRef.addChildEventListener (chEvListener);
        userRef.addValueEventListener(valEvListener);
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        if (mColumnCount <= 1) {
            recyclerView.setLayoutManager(new LinearLayoutManager(context));
        } else {
            recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
        }
        adapter = new JournalAdapter(allTrips, mListener);
        recyclerView.setAdapter(adapter);
    }
    return view;
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:26,代碼來源:JournalFragment.java

示例2: reauthenticate

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private void reauthenticate() {
    // [START reauthenticate]
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

    // Get auth credentials from the user for re-authentication. The example below shows
    // email and password credentials but there are multiple possible providers,
    // such as GoogleAuthProvider or FacebookAuthProvider.
    AuthCredential credential = EmailAuthProvider
            .getCredential("[email protected]", "password1234");

    // Prompt the user to re-provide their sign-in credentials
    user.reauthenticate(credential)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    Log.d(TAG, "User re-authenticated.");
                }
            });
    // [END reauthenticate]
}
 
開發者ID:firebase,項目名稱:snippets-android,代碼行數:21,代碼來源:MainActivity.java

示例3: getProfileData

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private static JSONObject getProfileData(FirebaseUser user) {
    JSONObject result = new JSONObject();

    try {
        result.put("uid", user.getUid());
        result.put("displayName", user.getDisplayName());
        result.put("email", user.getEmail());
        result.put("phoneNumber", user.getPhoneNumber());
        result.put("photoURL", user.getPhotoUrl());
        result.put("providerId", user.getProviderId());
    } catch (JSONException e) {
        Log.e(TAG, "Fail to process getProfileData", e);
    }

    return result;
}
 
開發者ID:chemerisuk,項目名稱:cordova-plugin-firebase-authentication,代碼行數:17,代碼來源:FirebaseAuthenticationPlugin.java

示例4: onCreate

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_media_details);
    ButterKnife.bind(this);

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    String uid = user.getUid();
    storageRef = FirebaseStorage.getInstance().getReference().child
            (uid);
    Intent incoming = getIntent();
    if (incoming.hasExtra("FIREBASE_REF")) {
        String fbUrl = incoming.getStringExtra("FIREBASE_REF");
        FirebaseDatabase db = FirebaseDatabase.getInstance();
        entriesRef = db.getReferenceFromUrl(fbUrl);
    }
    if (incoming.hasExtra("PHOTO_URI")) {
        mediaType = 2;
        try {
            dataUri = incoming.getParcelableExtra("PHOTO_URI");
            InputStream istr = getContentResolver().openInputStream
                    (dataUri);
            Bitmap bmp = BitmapFactory.decodeStream(istr);
            photoView.setImageBitmap(bmp);
            istr.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (incoming.hasExtra("VIDEO_URI")) {
        mediaType = 4;
        dataUri = incoming.getParcelableExtra("VIDEO_URI");
        videoView.setVideoURI(dataUri);
        MediaController mc = new MediaController(this);
        videoView.setMediaController(mc);
        photoView.setVisibility(View.INVISIBLE);
        videoView.setVisibility(View.VISIBLE);
    }
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:40,代碼來源:MediaDetailsActivity.java

示例5: startSession

import com.google.firebase.auth.FirebaseUser; //導入依賴的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

示例6: onStart

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
@Override
public void onStart() {
        super.onStart();
        // Check if user is signed in (non-null) and update UI accordingly.
        FirebaseUser currentUser = mAuth.getCurrentUser();
        mAuth.addAuthStateListener(new FirebaseAuth.AuthStateListener() {
                @Override
                public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {

                }
        });

        if (currentUser != null) {
                Intent i = new Intent(Login.this, MapsActivity.class);
                /*SharedPreferences prefs = Login.this.getSharedPreferences("contact", MODE_WORLD_READABLE);
                SharedPreferences.Editor prefsEditor = prefs.edit();
                prefsEditor.putString("password", password);
                prefsEditor.apply();*/
                startActivity(i);
        }

}
 
開發者ID:kuldeep725,項目名稱:VEHICLE-APP,代碼行數:23,代碼來源:Login.java

示例7: sendVerificationEmail

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private void sendVerificationEmail() {
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    user.sendEmailVerification()
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        // Email sent
                        finish();
                    } else {
                        // overridePendingTransition(0, 0);
                        // finish();
                        // overridePendingTransition(0, 0);
                        // startActivity(getIntent());
                        sendVerificationEmail();
                    }
                }
            });
}
 
開發者ID:akshayub,項目名稱:NITKart,代碼行數:20,代碼來源:newUser.java

示例8: initializeCurrentUserFirebaseListeners

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
public static void initializeCurrentUserFirebaseListeners() {
    FirebaseUser firebaseUser = getFirebaseUser();
    FirebaseDatabase database = FirebaseDatabase.getInstance();

    DatabaseReference userRef = database.getReference().child(FirebaseConstants.USERS).child(firebaseUser.getUid());
    userRef.addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            currentUser = dataSnapshot.getValue(User.class);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
}
 
開發者ID:lmnpWmi,項目名稱:wirtualnaApteczka,代碼行數:18,代碼來源:SessionManager.java

示例9: initializeFirebaseAuth

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private void initializeFirebaseAuth() {
        // Initialize Firebase Auth
        mAuth = FirebaseAuth.getInstance();
        mAuthListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser user = firebaseAuth.getCurrentUser();
                if (user != null) {
                    // User is signed in
                    Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
                } else {
                    // User is signed out
                    Log.d(TAG, "onAuthStateChanged:signed_out");
//                    signOut();
                }
            }
        };
    }
 
開發者ID:cache117,項目名稱:social-journal,代碼行數:19,代碼來源:SettingsActivity.java

示例10: testSignInWithEmailAndPassword

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
@Test public void testSignInWithEmailAndPassword() {
  mockSuccessfulAuthResult();

  when(mockFirebaseAuth.signInWithEmailAndPassword("email", "password")).thenReturn(
      mockAuthResultTask);

  TestObserver<FirebaseUser> obs = TestObserver.create();

  RxFirebaseAuth.signInWithEmailAndPassword(mockFirebaseAuth, "email", "password").subscribe(obs);

  callOnComplete(mockAuthResultTask);
  obs.dispose();

  // Ensure no more values are emitted after unsubscribe
  callOnComplete(mockAuthResultTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValueCount(1);
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:21,代碼來源:RxFirebaseAuthTest.java

示例11: initializeFirebaseListeners

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private void initializeFirebaseListeners() {
    FirebaseUser firebaseUser = SessionManager.getFirebaseUser();
    FirebaseDatabase database = FirebaseDatabase.getInstance();

    DatabaseReference userRef = database.getReference().child(FirebaseConstants.USERS).child(firebaseUser.getUid());
    userRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            User user = dataSnapshot.getValue(User.class);

            Map<String, Medicine> medicinesMap = user.getMedicines();
            List<Medicine> currentUserMedicines = new ArrayList<>(medicinesMap.values());

            initializeRecentlyUsedMedicinesList(currentUserMedicines);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
}
 
開發者ID:lmnpWmi,項目名稱:wirtualnaApteczka,代碼行數:22,代碼來源:MainActivity.java

示例12: onComplete

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
    int messageId = R.string.user_not_registered;

    if (task.isSuccessful()) {
        FirebaseAuth firebaseAuth = SessionManager.getFirebaseAuth();
        FirebaseUser currentUser = firebaseAuth.getCurrentUser();

        if (currentUser != null) {
            currentUser.sendEmailVerification();
            DbService dbService = SessionManager.getDbService();
            dbService.createOrUpdateUserAccountInFirebase(userRegistrationTO);

            messageId = R.string.verification_email_sent;
        }

        Intent intent = new Intent(context, LogInActivity.class);
        context.startActivity(intent);
    }

    Toast.makeText(context, messageId, Toast.LENGTH_SHORT).show();
}
 
開發者ID:lmnpWmi,項目名稱:wirtualnaApteczka,代碼行數:23,代碼來源:RegistrationOnCompleteListener.java

示例13: setNumberOfMushroomsToUI

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private void setNumberOfMushroomsToUI(DatabaseReference databaseReference, FirebaseUser firebaseUser) {
    databaseReference.child("users")
            .child(firebaseUser.getUid())
            .addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    // Update the android UI
                    setNumberOfMushroomsToUI(dataSnapshot.getValue(User.class).getNumberOfMushrooms());
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    Log.e(TAG, "Database Error Occurred", databaseError.toException());
                    FirebaseCrash.report(databaseError.toException());
                }
            });
}
 
開發者ID:moizalicious,項目名稱:Forager,代碼行數:18,代碼來源:AccountSettings.java

示例14: setDistanceRemainingToUI

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private void setDistanceRemainingToUI(final DatabaseReference databaseReference, FirebaseUser firebaseUser) {
    databaseReference.child("global")
            .child("distanceRemaining")
            .addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    // Update the android UI
                    setDistanceRemainingToUI(dataSnapshot.getValue(Long.class).intValue());
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    Log.e(TAG, "Database Error Occurred", databaseError.toException());
                    FirebaseCrash.report(databaseError.toException());
                }
            });
}
 
開發者ID:moizalicious,項目名稱:Forager,代碼行數:18,代碼來源:Community.java

示例15: subtractFromDistanceRemaining

import com.google.firebase.auth.FirebaseUser; //導入依賴的package包/類
private void subtractFromDistanceRemaining(final DatabaseReference databaseReference, FirebaseUser firebaseUser) {
    databaseReference.child("global")
            .child("distanceRemaining")
            .addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    // Update the database
                    subtractFromDistanceRemaining(databaseReference, (dataSnapshot.getValue(Long.class).intValue() - 1));
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    Log.e(TAG, "Database Error Occurred", databaseError.toException());
                    FirebaseCrash.report(databaseError.toException());
                }
            });
}
 
開發者ID:moizalicious,項目名稱:Forager,代碼行數:18,代碼來源:StartGame.java


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