本文整理汇总了Java中com.firebase.client.Firebase.AuthStateListener方法的典型用法代码示例。如果您正苦于以下问题:Java Firebase.AuthStateListener方法的具体用法?Java Firebase.AuthStateListener怎么用?Java Firebase.AuthStateListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.firebase.client.Firebase
的用法示例。
在下文中一共展示了Firebase.AuthStateListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: settingFirebase
import com.firebase.client.Firebase; //导入方法依赖的package包/类
/**
* ***************************************************************************
*/
private Firebase settingFirebase(String urlFirebase, String child) {
Firebase firebase = new Firebase(urlFirebase).child(child);
firebase.authWithPassword(mUsernameMail, mUsernamePwd, new AuthResultHandler("password"));
mAuthStateListener = new Firebase.AuthStateListener() {
@Override
public void onAuthStateChanged(AuthData authData) {
setAuthenticatedUser(authData);
}
};
firebase.addAuthStateListener(mAuthStateListener);
firebase.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
mAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
return firebase;
}
示例2: onCreate
import com.firebase.client.Firebase; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestScopes(new Scope(Scopes.PLUS_ME))
.requestScopes(new Scope("https://picasaweb.google.com/data/"))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
mGoogleLoginButton.setSize(SignInButton.SIZE_WIDE);
mFirebaseRef = new Firebase(Constants.FIREBASE_URL);
mAuthProgressDialog = new ProgressDialog(this);
mAuthProgressDialog.setTitle(getString(R.string.login_activity_progress_dialog_title));
mAuthProgressDialog.setMessage(getString(R.string.login_activity_progress_dialog_message));
mAuthProgressDialog.setCancelable(false);
mAuthProgressDialog.show();
mAuthStateListener = new Firebase.AuthStateListener() {
@Override
public void onAuthStateChanged(AuthData authData) {
mAuthProgressDialog.dismiss();
/**
* If there is a valid session to be restored, start MainActivity.
* No need to pass data via SharedPreferences because app
* already holds userName/provider data from the latest session
*/
if (authData != null) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
}
}
};
}