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


Java FirebaseAuth类代码示例

本文整理汇总了Java中com.google.firebase.auth.FirebaseAuth的典型用法代码示例。如果您正苦于以下问题:Java FirebaseAuth类的具体用法?Java FirebaseAuth怎么用?Java FirebaseAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FirebaseAuth类属于com.google.firebase.auth包,在下文中一共展示了FirebaseAuth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLocationChanged

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    FirebaseAuth auth = FirebaseAuth.getInstance();
    String uid = auth.getCurrentUser().getUid();
    DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("users");
    ref.child(uid).child("location").setValue(new Loc(location.getLatitude(), location.getLongitude()));

    SharedPreferences prefs = context.getSharedPreferences("USER_DATA", 0);
    String group_id = prefs.getString("GROUP_ID", "");

    GeoHash geoHash = new GeoHash(location.getLatitude(), location.getLongitude());
    Map<String, Object> updates = new HashMap<String, Object>();
    updates.put("g", geoHash.getGeoHashString());
    updates.put("l", Arrays.asList(location.getLatitude(), location.getLongitude()));

    FirebaseDatabase.getInstance().getReference()
            .child("group_locations")
            .child(group_id)
            .child(uid)
            .setValue(updates);
    EventBus.getDefault().post(location);
}
 
开发者ID:mremondi,项目名称:Hyke,代码行数:23,代码来源:HykeLocationManager.java

示例2: onCreate

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_in);

    // 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
    mFirebaseAuth = FirebaseAuth.getInstance();
}
 
开发者ID:YoWenqin,项目名称:BuddiesGo,代码行数:25,代码来源:SignInActivity.java

示例3: getUserObject

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
private void getUserObject(){
    mAuth = FirebaseAuth.getInstance();
    userID = mAuth.getCurrentUser().getUid();
    token = FirebaseInstanceId.getInstance().getToken();
    mUserManager = new UserManager();
    mUserManager.getUser(userID, new IGetUserListener() {
        @Override
        public void onGetSingleUser(User retrievedUser) {
            mUser = retrievedUser;
            // 11/28/17 JD: then instantiate the UI so that we can't move forward until a user value is found
            createStartShiftButton();
        }

        @Override
        public void onFailedSingleUser() {
            // 11/28/17 JD: do something to avoid catastrophic failure

        }
    });
}
 
开发者ID:panzerama,项目名称:Dispatch,代码行数:21,代码来源:ShiftStartActivity.java

示例4: handleMessage

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
private void handleMessage(RemoteMessage remoteMessage) {

        Intent intent = new Intent(this, FirebaseAuth.getInstance().getCurrentUser() == null ? LoginActivity.class:MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent intent1 = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);


        Uri defaultURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this,NotificationCompat.CATEGORY_MESSAGE)
                .setSmallIcon(R.drawable.gdg_notification_icon)
                .setContentTitle(remoteMessage.getNotification().getTitle())
                .setContentText(remoteMessage.getNotification().getBody())
                .setAutoCancel(true)
                .setSound(defaultURI)
                .setContentIntent(intent1);

        NotificationManager manager =  ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
        if (manager != null) {
            manager.notify(23,builder.build());
        }


    }
 
开发者ID:coder3101,项目名称:gdgApp,代码行数:25,代码来源:MessagingService.java

示例5: onOptionsItemSelected

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    int id = item.getItemId();

    switch (item.getItemId()) {
        case R.id.sign_out_menu:
            FirebaseAuth.getInstance().signOut();
            Intent intent = new Intent(SectionsActivity.this, StartActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);
            finish();
            return true;
        case R.id.action_settings:
            Intent settings = new Intent(this, SettingsActivity.class);

            startActivity(settings);
            return true;
        default:
            return super.onOptionsItemSelected(item);


    }
}
 
开发者ID:roy09,项目名称:AyyMate-Android-RealtimeChat,代码行数:26,代码来源:SectionsActivity.java

示例6: signUp

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Override
public void signUp(final String email, final String password) {
    FirebaseAuth.getInstance().createUserWithEmailAndPassword(email, password)
            .addOnSuccessListener(new OnSuccessListener<AuthResult>() {
                @Override
                public void onSuccess(AuthResult authResult) {
                    postEvent(LoginEvent.onSignUpSuccess);
                    signIn(email, password);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    postEvent(LoginEvent.onSignUpError, e.getMessage());
                }
            });
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:18,代码来源:LoginRepositoryImpl.java

示例7: signInFailure_ShowsErrorMessage

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Test
@SuppressWarnings("ConstantConditions")
public void signInFailure_ShowsErrorMessage() throws Exception {

    FirebaseAuth.getInstance().signOut();
    FakeAuthConnector.setFakeSuccess(false);

    createActivity();

    // error message should be showing:
    Espresso.onView(withId(R.id.progressBar)).check(matches(not(isDisplayed())));
    Espresso.onView(withId(R.id.textMessage)).check(matches(isDisplayed()));
    Espresso.onView(withId(R.id.buttonContinue)).check(matches(isDisplayed()));

    // double check that the home screen is not shown:
    Espresso.onView(withId(R.id.recyclerContent)).check(doesNotExist());
}
 
开发者ID:Frank1234,项目名称:FireBaseTest,代码行数:18,代码来源:SignInScreenTest.java

示例8: authListener

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Override
public void authListener(final OnLoginFinishedListener listener){
    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            user = firebaseAuth.getCurrentUser();
            if (user != null) {
               if(signInWithGoogle){
                  listener.onLoginGoogleSuccess();

                }
                else if(registerWithMail){
                    listener.onRegisterMailSuccess();
                }
                else {
                   listener.onLoginMailSuccess();
               }

            } else {
                // User is signed out
                // Log.d(TAG, "onAuthStateChanged:signed_out");
            }
        }
    };
}
 
开发者ID:jcolladosp,项目名称:PimPam,代码行数:26,代码来源:LoginInteractorImpl.java

示例9: getAllUsersFromFirebase

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Override
public void getAllUsersFromFirebase() {
    FirebaseDatabase.getInstance().getReference().child(Constants.ARG_USERS).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Iterator<DataSnapshot> dataSnapshots = dataSnapshot.getChildren().iterator();
            List<User> users = new ArrayList<>();
            while (dataSnapshots.hasNext()) {
                DataSnapshot dataSnapshotChild = dataSnapshots.next();
                User user = dataSnapshotChild.getValue(User.class);
                if (!TextUtils.equals(user.uid, FirebaseAuth.getInstance().getCurrentUser().getUid())) {
                    users.add(user);
                }
            }
            mOnGetAllUsersListener.onGetAllUsersSuccess(users);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            mOnGetAllUsersListener.onGetAllUsersFailure(databaseError.getMessage());
        }
    });
}
 
开发者ID:mustafaozhan,项目名称:Howl,代码行数:24,代码来源:GetUsersInteractor.java

示例10: getCurrentUser

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public GdxFirebaseUser getCurrentUser()
{
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user == null) return null;
    UserInfo.Builder builder = new UserInfo.Builder();
    builder.setDisplayName(user.getDisplayName())
            .setPhotoUrl(user.getPhotoUrl() != null ? user.getPhotoUrl().getPath() : null)
            .setProviderId(user.getProviderId())
            .setUid(user.getUid())
            .setIsEmailVerified(user.isEmailVerified())
            .setIsAnonymous(user.isAnonymous())
            .setEmail(user.getEmail());
    return GdxFirebaseUser.create(builder.build());
}
 
开发者ID:mk-5,项目名称:gdx-fireapp,代码行数:19,代码来源:Auth.java

示例11: deleteUserFromDatabase

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
/**
 * Delete a user from the database
 */
public void deleteUserFromDatabase() {
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        String userId = user.getUid();
        getDatabaseManager().deleteUserRecords(getActivity(), userId);
        user.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
            /**
             * Delete the user task completed
             * @param task - the completed task
             */
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    mUser = null;
                }
            }
        });
        resetDatabaseManager();
    }
}
 
开发者ID:iskandergaba,项目名称:Botanist,代码行数:24,代码来源:AccountController.java

示例12: onOptionsItemSelected

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

   if (id == R.id.action_contact_us) {
        contactUs();
        return true;
    }else if (id == R.id.action_logout) {
        //facebook logout
        LoginManager.getInstance().logOut();
        //firebase logout
        FirebaseAuth.getInstance().signOut();
        logout = true;
        startActivity(new Intent(this,LoginActivity.class));
        return true;
    }else if (id == R.id.item_samplebadge) {
        Intent intent = new Intent(this,ShoppingCardActivity.class);
        intent.putParcelableArrayListExtra("order",cardItems);
        startActivity(intent);

        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:OmarAliSaid,项目名称:android-paypal-example,代码行数:26,代码来源:ProductsActivity.java

示例13: 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

示例14: getProviderData

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
private void getProviderData() {
    // [START get_provider_data]
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        for (UserInfo profile : user.getProviderData()) {
            // Id of the provider (ex: google.com)
            String providerId = profile.getProviderId();

            // UID specific to the provider
            String uid = profile.getUid();

            // Name, email address, and profile photo Url
            String name = profile.getDisplayName();
            String email = profile.getEmail();
            Uri photoUrl = profile.getPhotoUrl();
        };
    }
    // [END get_provider_data]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:20,代码来源:MainActivity.java

示例15: onCreateView

import com.google.firebase.auth.FirebaseAuth; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.frag_request,container,false);

    mRequests = new ArrayList<>();

    mAuth = FirebaseAuth.getInstance();
    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            mUser = firebaseAuth.getCurrentUser();

        }
    };

    //mRequests.add(new Request("Name1","9PM"));
    //mRequests.add(new Request("Name2","9PM"));
    //mRequests.add(new Request("Name3","9PM"));

    initViews();
    setUpRecyclerView();
    getRequests();

    return mView;
}
 
开发者ID:PalisadoesFoundation,项目名称:do-road,代码行数:27,代码来源:ReqeustFragment.java


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