本文整理匯總了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;
}
示例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]
}
示例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);
}
}
示例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 );
}
}
示例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);
}
}
示例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();
}
}
});
}
示例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) {
}
});
}
示例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();
}
}
};
}
示例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);
}
示例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) {
}
});
}
示例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();
}
示例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());
}
});
}
示例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());
}
});
}
示例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());
}
});
}