Ich kann das Facebook-Profilbild des Benutzers nicht in mein imageView erhalten. Ich versuche, mit Picasso Bibliothek zu bekommen. Haben Sie eine Idee, das zu lösen? Hier sind meine Codes. Danke im Voraus!Kann FB Profilbild mit Firebase nicht bekommen
R.string.facebook_provider_id = "facebook.com"
Fehler:
FATAL EXCEPTION: main
Process: com.example.yunus.ototakip, PID: 3045 java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.yunus.ototakip/com.example.yunus.ototakip.Hesabim}: java.lang.IllegalArgumentException: Target must not be null.
Hesabim.java
public class Hesabim extends AppCompatActivity {
public FirebaseAuth firebaseAuth;
public FirebaseUser user;
public CircleImageView userImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hesabim);
userImage= (CircleImageView) findViewById(R.id.kullaniciHesapResmi);
firebaseAuth = FirebaseAuth.getInstance();
user = FirebaseAuth.getInstance().getCurrentUser();
if(firebaseAuth.getCurrentUser()==null)
{
finish();
startActivity(new Intent(this,Giris.class));
}
kullaniciMail.setText(firebaseAuth.getCurrentUser().getEmail());
String facebookUserId = "";
user = FirebaseAuth.getInstance().getCurrentUser();
for(UserInfo profile : user.getProviderData()) {
// check if the provider id matches "facebook.com"
if(profile.getProviderId().equals(getString(R.string.facebook_provider_id))) {
facebookUserId = profile.getUid();
}
}
String photoUrl = "https://graph.facebook.com/" + facebookUserId + "/picture?type=medium";
Picasso.with(this).load(photoUrl).into(userImage);
hesabim.xml
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/kullaniciHesapResmi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/kullanici_pp"
fancy:civ_border_color="@color/colorAccent"
fancy:civ_border_width="2dp" />
Mein Code ist inklusive loginButton.setReadPermissions ("E-Mail", "public_profile"); Linie. –
Sollte ich Ihren Code in meiner LoginActivity oder Aktivität verwenden, die nach LoginActivity geöffnet wird? –
Verwenden Sie diesen Code in der Login-Aktivität. Und Bild zur nächsten Aktivität weitergeben. –