本文整理汇总了Java中com.google.firebase.auth.FirebaseAuth.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseAuth.getInstance方法的具体用法?Java FirebaseAuth.getInstance怎么用?Java FirebaseAuth.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.auth.FirebaseAuth
的用法示例。
在下文中一共展示了FirebaseAuth.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Initialize FirebaseAuth
mFirebaseAuth = FirebaseAuth.getInstance();
// Assign fields
mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);
// Set click listeners
mSignInButton.setOnClickListener(this);
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
// Initialize FirebaseAuth
}
示例4: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
counter =0;
mAuth = FirebaseAuth.getInstance();
databaseFamilies = FirebaseDatabase.getInstance().getReference("Families");
setContentView(R.layout.activity_app_login);
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
//Signs in user with Google sign in
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// Check if user is signed in (non-null)
FirebaseUser currentUser = mAuth.getCurrentUser();
// Add user to database
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
}
});
}
示例5: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize Firebase Auth
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
if (mFirebaseUser != null) {
mUsername = mFirebaseUser.getDisplayName();
mUID = mFirebaseUser.getUid();
Intent intent = new Intent(this, DisplayCatActivity.class);
intent.putExtra(USERNAME, mUsername);
intent.putExtra(USERID, mUID);
startActivity(intent);
}
}
示例6: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_home);
setContentView(R.layout.fragment_feed);
Log.d(TAG, "onCreate: starting");
setupBottomNavigationBar();
mAuth = FirebaseAuth.getInstance();
mDatabase = FirebaseDatabase.getInstance();
mFeed = findViewById(R.id.myFeed);
Log.d(TAG, mFeed.toString());
listAdapter = new MainFeedListAdapter(HomeActivity.this, R.layout.layout_feed_list_item, posts);
mFeed.setAdapter(listAdapter);
downloadMyFeed();
}
示例7: startSession
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的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 );
}
}
示例8: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_registration);
auth = FirebaseAuth.getInstance();
appStatus=new AppStatus(getApplicationContext());
register = (Button) findViewById(R.id.btn_register);
existinguser = (Button) findViewById(R.id.existinguser);
edt_Password = (EditText) findViewById(R.id.edt_Rpassword);
edt_RePassword = (EditText) findViewById(R.id.edt_RRepassword);
edt_Email = (EditText) findViewById(R.id.edt_email);
progressBar=(ProgressBar)findViewById(R.id.progressBar);
register.setOnClickListener(this);
existinguser.setOnClickListener(this);
}
示例9: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
mAuth = FirebaseAuth.getInstance();
shake = AnimationUtils.loadAnimation(this, R.anim.shake);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
示例10: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
if (!calledAlready) {
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
calledAlready = true;
}
super.onCreate(savedInstanceState);
// Initialize Firebase Auth and Database Reference
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
if (mFirebaseUser!= null) {
startActivity(new Intent(this, MainActivity.class));
finish();
}
setContentView(R.layout.activity_welcome);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Not logged in, Therefore remain.
ImageView welcomeLogo = (ImageView) findViewById(R.id.welcome_logo);
Button logInButton = (Button) findViewById(R.id.loginButton);
Button signInButton = (Button) findViewById(R.id.signinButton);
Glide.with(this).load(R.drawable.ic_web)
.placeholder(R.drawable.ic_web)
.into(welcomeLogo);
logInButton.setOnClickListener(this);
signInButton.setOnClickListener(this);
}
示例11: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_login);
splashActivity=new SplashActivity();
prop=new Properties();
auth = FirebaseAuth.getInstance();
appStatus=new AppStatus(getApplicationContext());
str_getEmail = SplashActivity.sh.getString("email", null);
str_getPass = SplashActivity.sh.getString("password", null);
login = (Button) findViewById(R.id.btn_login);
newuser = (Button) findViewById(R.id.newuser);
edt_Email = (EditText) findViewById(R.id.edt_email);
edt_Password = (EditText) findViewById(R.id.edt_password);
progressBar=(ProgressBar)findViewById(R.id.progressBar);
b=splashActivity.containsPass("password");
if(b==true){
}
login.setOnClickListener(this);
newuser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this,RegistrationActivity.class));
}
});
}
示例12: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
ActionBar actionBar = getSupportActionBar();
sharedPreferences = getApplicationContext().getSharedPreferences("event_me", Context.MODE_PRIVATE);
if(actionBar!=null)
actionBar.hide();
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.api_client_id))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
signInButton = (SignInButton)findViewById(R.id.sign_in_button);
signInButton.setOnClickListener(this);
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");
}
}
};
mDatabase = FirebaseDatabase.getInstance().getReference();
}
示例13: onCreate
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_journal);
ButterKnife.bind(this);
Intent data = getIntent();
if (data.hasExtra("TRIP")) {
toolbar.setTitle("Edit Journal");
Parcelable par = data.getParcelableExtra("TRIP");
currentTrip = Parcels.unwrap(par);
FirebaseAuth auth = FirebaseAuth.getInstance();
String uid = auth.getCurrentUser().getUid();
DatabaseReference ref = FirebaseDatabase.getInstance()
.getReference(uid).child(currentTrip.getKey())
.child("entries");
photoFrag = PhotoFragment.newInstance(ref.toString());
getSupportFragmentManager().beginTransaction()
.add(R.id.container, photoFrag)
.commit();
jname.setText(currentTrip.getName());
location.setText(currentTrip.getLocation());
startDateView.setText(formatted(DateTime.parse(currentTrip
.getStartDate())));
endDateView.setText(formatted(DateTime.parse(currentTrip.getEndDate())));
startDate = DateTime.parse(currentTrip.getStartDate());
endDate = DateTime.parse(currentTrip.getEndDate());
} else {
toolbar.setTitle("New Journal");
currentTrip = new Trip();
DateTime today = DateTime.now();
startDateView.setText(formatted(today));
endDateView.setText(formatted(today.plusDays(1)));
startDate = today;
endDate = today.plusDays(1);
}
dpDialog = DatePickerDialog.newInstance(this,
startDate.getYear(), startDate.getMonthOfYear() - 1, startDate
.getDayOfMonth());
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
示例14: provideFirebaseAuth
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
@Provides
@Singleton
FirebaseAuth provideFirebaseAuth() {
return FirebaseAuth.getInstance();
}
示例15: AuthSourceImpl
import com.google.firebase.auth.FirebaseAuth; //导入方法依赖的package包/类
AuthSourceImpl() {
this.mFirebaseAuth = FirebaseAuth.getInstance();
}