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


Java Firebase.AuthStateListener方法代码示例

本文整理汇总了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;

}
 
开发者ID:benslamajihed,项目名称:GalleryPictureFirebaseAndroid,代码行数:30,代码来源:GalleryActivity.java

示例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();
            }
        }
    };
}
 
开发者ID:trigor74,项目名称:travelers-diary,代码行数:49,代码来源:LoginActivity.java


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