本文整理匯總了Java中com.google.firebase.auth.FirebaseAuth.getCurrentUser方法的典型用法代碼示例。如果您正苦於以下問題:Java FirebaseAuth.getCurrentUser方法的具體用法?Java FirebaseAuth.getCurrentUser怎麽用?Java FirebaseAuth.getCurrentUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.firebase.auth.FirebaseAuth
的用法示例。
在下文中一共展示了FirebaseAuth.getCurrentUser方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的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: sendEmailVerification
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
public void sendEmailVerification() {
// [START send_email_verification]
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
user.sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Email sent.");
}
}
});
// [END send_email_verification]
}
示例3: onCreate
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
if (null != actionBar) actionBar.hide();
ButterKnife.bind(this);
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
showWhiteSnackBar(R.string.sign_in_successful);
googleLoginButton.setVisibility(View.INVISIBLE);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
}
示例4: onCreateView
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_journal_list, container, false);
Bundle data = getArguments();
int cellLayout = data.getInt(ARG_LAYOUT);
// 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;
recyclerView.setLayoutManager(new LinearLayoutManager(context));
adapter = new JournalAdapter(selectedTrips, cellLayout, mListener);
recyclerView.setAdapter(adapter);
}
return view;
}
示例5: onCreate
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dispacth_activity);
container = findViewById(R.id.dispatcher_container);
/** If this wasn't a non common dispatch activity we would change
* the theme with setTheme() for removing the splashScreen theme
* and setting the correct here.
*/
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth != null && auth.getCurrentUser() != null) {
// signed in
Intent startMainActivityIntent = new Intent(this, BookListsActivity.class);
startMainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(startMainActivityIntent);
} else {
// not signed in
goToLoginActivity();
}
}
示例6: onStart
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
public void onStart() {
super.onStart();
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser == null) {
Intent i = new Intent(MapsActivity.this, Login.class);
startActivity(i);
finish();
}
else {
/*SharedPreferences myPrefs = this.getSharedPreferences("contact", MODE_WORLD_READABLE);
userId = myPrefs.getString("email", "none");*/
userId = currentUser.getEmail();
}
Log.d(TAG, "onStart fired ..............");
mGoogleApiClient.connect();
if (!checkPermissions()) {
requestPermissions();
}
}
示例7: onCreate
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_view);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
entries.setLayoutManager(new LinearLayoutManager(this));
Retrofit retro = new Retrofit.Builder()
.baseUrl("https://api.darksky.net/")
.addConverterFactory(GsonConverterFactory.create())
.build();
darkSkyClient = retro.create(DarkSkyServices.class);
Intent incoming = getIntent();
if (incoming.hasExtra("TRIP")) {
Parcelable par = incoming.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
tripKey = t.getKey();
title.setText(t.getName());
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
entriesRef = dbRef.getReference(user.getUid())
.child(tripKey + "/entries").orderByChild("date");
storage = FirebaseStorage.getInstance();
adapter = new MyAdapter();
entries.setAdapter(adapter);
entries.addItemDecoration(verticalGap);
}
}
示例8: checkLogin
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
public boolean checkLogin()
{
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
if (firebaseAuth.getCurrentUser() != null)
{
return true;
}
return false;
}
示例9: onAuthStateChanged
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
if (firebaseUser == null) {
mData = new ArrayList<>();
updateWidget();
} else {
loadBookList();
}
}
示例10: onResume
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
public void onResume(){
super.onResume();
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser mUser = mAuth.getCurrentUser();
String uid = mUser.getUid();
topRef = dbRef.getReference(uid);
}
示例11: updateFirebaseDatabase
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
private static void updateFirebaseDatabase(Context context) {
Cursor cursor;
try {
cursor = context.getContentResolver().query(TaskItemsContract.TaskItemsColumns.CONTENT_URI,
null,
null,
null,
null);
} catch (Exception e) {
Log.e(TAG, "Failed to asynchronously load data.");
e.printStackTrace();
return;
}
if (null == cursor) {
return;
}
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference("users");
Map<String, TaskItem> usersTask = new HashMap<String, TaskItem>();//
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
if (null == user) {
return;
}
DatabaseReference userId = mDatabase.child(user.getUid()).child(TaskItemsContract.PATH_TASK_ITEMS);
while (cursor.moveToNext()) {
int idIndex = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns._ID);
int itemDescriptionIndex = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_DESCRIPTION);
int colorIndex = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_COLOR);
int isFinishedIndex = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_IS_FINISHED);
int isTodayIndex = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_IS_TODAY);
int createdOn = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_CREATED_AT);
int streak = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_STREAK);
int dateList = cursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_COMPLETED_DATES);
TaskItem taskItem = new TaskItem();
taskItem.setColor(cursor.getInt(colorIndex));
taskItem.setDescription(cursor.getString(itemDescriptionIndex));
taskItem.setIsFinished(cursor.getInt(isFinishedIndex));
taskItem.setIsToday(cursor.getInt(isTodayIndex));
taskItem.setCreatedOn(cursor.getString(createdOn));
taskItem.setStreak(cursor.getInt(streak));
taskItem.setListDates(cursor.getString(dateList));
usersTask.put(cursor.getString(idIndex), taskItem);
}
cursor.close();
userId.setValue(usersTask);
Log.e(TAG, "fire_update");
}
示例12: onCreate
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_view);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
entries.setLayoutManager(new LinearLayoutManager(this));
FirebaseImageLoader imgLoader = new FirebaseImageLoader();
Intent incoming = getIntent();
if (incoming.hasExtra("TRIP")) {
Parcelable par = incoming.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
tripKey = t.getKey();
title.setText(t.getName());
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
entriesRef = dbRef.getReference(user.getUid())
.child(tripKey + "/entries");
storage = FirebaseStorage.getInstance();
adapter = new FirebaseRecyclerAdapter<JournalEntry, EntryHolder>
(JournalEntry.class, R.layout.journal_entry_item,
EntryHolder.class, entriesRef) {
@Override
protected void populateViewHolder(EntryHolder viewHolder, JournalEntry model, int position) {
viewHolder.setCaption(model.getCaption());
viewHolder.setDate(model.getDate());
switch (model.getType()) {
case 2: // photo
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.GONE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl(model.getUrl()))
.into(viewHolder.topImage);
break;
case 4: // video
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.VISIBLE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl
(model.getThumbnailUrl()))
.into(viewHolder.topImage);
break;
default:
viewHolder.topImage.setVisibility(View.GONE);
break;
}
viewHolder.editBtn.setOnClickListener( view -> {
String key = getRef(position).getKey();
toMediaEdit(model, key);
});
viewHolder.topImage.setOnClickListener( view -> {
toMediaView(model);
});
}
};
entries.setAdapter(adapter);
}
}
示例13: onCreate
import com.google.firebase.auth.FirebaseAuth; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_view);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
entries.setLayoutManager(new LinearLayoutManager(this));
FirebaseImageLoader imgLoader = new FirebaseImageLoader();
Intent incoming = getIntent();
if (incoming.hasExtra("TRIP")) {
Parcelable par = incoming.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
tripKey = t.getKey();
title.setText(t.getName());
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
entriesRef = dbRef.getReference(user.getUid())
.child(tripKey + "/entries");
storage = FirebaseStorage.getInstance();
adapter = new FirebaseRecyclerAdapter<JournalEntry, EntryHolder>
(JournalEntry.class, R.layout.journal_entry_item,
EntryHolder.class, entriesRef) {
@Override
protected void populateViewHolder(EntryHolder viewHolder, JournalEntry model, int position) {
viewHolder.setCaption(model.getCaption());
viewHolder.setDate(model.getDate());
switch (model.getType()) {
case 1:
viewHolder.mediaContainer.setVisibility(View
.GONE);
break;
case 2: // photo
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.GONE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl(model.getUrl()))
.into(viewHolder.topImage);
break;
case 3: // audio
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.VISIBLE);
break;
case 4: // video
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.VISIBLE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl
(model.getThumbnailUrl()))
.into(viewHolder.topImage);
break;
default:
viewHolder.topImage.setVisibility(View.GONE);
break;
}
viewHolder.editBtn.setOnClickListener( view -> {
String key = getRef(position).getKey();
toMediaEdit(model, key);
});
viewHolder.topImage.setOnClickListener( view -> {
toMediaView(model);
});
viewHolder.playIcon.setOnClickListener( view -> {
toMediaView(model);
});
}
};
entries.setAdapter(adapter);
entries.addItemDecoration(verticalGap);
}
}