Firebase Auth: Android: Unable to display user email and photo

亡梦爱人 提交于 2019-12-06 09:11:48

Uri refrence is always null. Try to store it as string like this:

String uri =  userInfo.getPhotoUrl().toString;

And pass it to preference, then set it like this:

String fbImage = pref.getString("ImageUri", "");

if (fbImage != null && !fbImage.isEmpty()) {
            Picasso.with(getApplicationContext())
                    .load(fbImage)
                    .placeholder(R.drawable.img_circle_placeholder)
                    .resize(avatarSize, avatarSize)
                    .centerCrop()
                    .transform(new CircleTransformation())
                    .into(ImageViewObject);

        }

Make sure you added picasso dependency to your gradle.

 compile 'com.squareup.picasso:picasso:2.3.2'

for emailID:

String email = pref.getString("email", null);

//try to check here
Log.w("email", ""+email);

if(email != null && !email.isEmpty()){
   textEmail.setText(""+email);
}

or you can use intent service this is work for sure:

In you login activity:

Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("email_id", email_id);
startActivity(intent);
finish();

and in your mainActivity:

Intent intent = getIntent();
String email = intent.getStringExtra("email_id");

textEmail.setText(""+email);

update-2

there is one firebase method.. and its easiest way to do it.

write this code in your second activity where you want to retrive data..

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
TextView email;

email.setText(""+ user.getEmail());

there is no need of sharedPrefrence or intent service.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!