當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。