当前位置: 首页>>代码示例>>Java>>正文


Java FirebaseAuth.getCurrentUser方法代码示例

本文整理汇总了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;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:26,代码来源:JournalFragment.java

示例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]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:17,代码来源:MainActivity.java

示例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();
    }

}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:22,代码来源:LoginActivity.java

示例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;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:23,代码来源:JournalFragment.java

示例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();
  }
}
 
开发者ID:paulnunezm,项目名称:Boookito-Capstone-Project,代码行数:28,代码来源:DispatchActivity.java

示例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();
        }
}
 
开发者ID:kuldeep725,项目名称:gogo,代码行数:23,代码来源:MapsActivity.java

示例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);
    }
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:30,代码来源:JournalViewActivity.java

示例8: checkLogin

import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
public boolean checkLogin()
{
    FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
    if (firebaseAuth.getCurrentUser() != null)
    {
        return true;
    }
    return false;
}
 
开发者ID:icaynia,项目名称:pracler,代码行数:10,代码来源:Splash.java

示例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();
    }

}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:14,代码来源:BuddyBookWidgetService.java

示例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);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:10,代码来源:MainActivity.java

示例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");
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:48,代码来源:UpdateProgressTasks.java

示例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);
    }
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:65,代码来源:JournalViewActivity.java

示例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);
    }
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:77,代码来源:JournalViewActivity.java


注:本文中的com.google.firebase.auth.FirebaseAuth.getCurrentUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。