GithubHelp home page GithubHelp logo

Comments (6)

tikurahul avatar tikurahul commented on June 19, 2024 8

This is a bug in the sample code. FirebaseUser#getPhotoUrl actually returns a nullable Uri.
Replace user.getPhotoUrl().toString() with user.getPhotoUrl() != null ? user.getPhotoUrl().toString() : null.

Better yet, you can submit a PR to fix the issue. 👍

from friendlypix.

geraldokandonga avatar geraldokandonga commented on June 19, 2024

Hi i am also having the same problem with this code similar to above post

FirebaseUser mUser = mFirebaseAuth.getCurrentUser();
if (mUser != null) {
// User is signed in
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
String uid = mFirebaseAuth.getCurrentUser().getUid();
THIS LINE String image = mFirebaseAuth.getCurrentUser().getPhotoUrl().toString();
intent.putExtra("user_id", uid);
if(image!=null){
intent.putExtra("profile_picture",image);
}
startActivity(intent);
startActivity(intent);
finish();
Log.d(TAG, "onAuthStateChanged:signed_in:" + mUser.getUid());
}

any help

from friendlypix.

jamespinto avatar jamespinto commented on June 19, 2024

What is the solution for this?

the following suggestion by tikurahul dint work

Replace user.getPhotoUrl().toString() with user.getPhotoUrl() != null ? user.getPhotoUrl().toString() : null

from friendlypix.

migueltarga avatar migueltarga commented on June 19, 2024
public static Author getAuthor() {
        FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
        if (user == null) return null;
        return new Author(user.getDisplayName(), user.getPhotoUrl() != null ? user.getPhotoUrl().toString() : null, user.getUid());
    }

@jamespinto I agree with @tikurahul this should fix it, if the error in this line is:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference

from friendlypix.

jamespinto avatar jamespinto commented on June 19, 2024

nope! not working. I am using the google signin provider to log the user in.
According to the google documentation (the below code also gives me the same nullpointer exception)

Get a user's provider-specific profile information

To get the profile information retrieved from the sign-in providers linked to a user, use the getProviderData method. For example:

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();
    };
}

https://firebase.google.com/docs/auth/android/manage-users#get_a_users_provider-specific_profile_information

from friendlypix.

gkaldev avatar gkaldev commented on June 19, 2024

This issue was moved to googlearchive/friendlypix-android#27

from friendlypix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.