Closed gkaldev closed 6 years ago
From @tikurahul on May 29, 2016 18:16
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 @gkfillipus on August 5, 2016 21:48
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 @jamespinto on January 20, 2017 13:11
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 @migueltarga on January 20, 2017 13:19
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 @jamespinto on January 20, 2017 13:34
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();
};
}
Cleaning up issue fixed in upcoming v2.
From @VihaanVerma89 on May 29, 2016 17:6
I'm getting null pointer exception on loading image post. Uri returned from user.getPhotoUrl() is null
Logcat
Copied from original issue: firebase/friendlypix#12