如何将从 facebook 登录获得的个人资料图片设置为另一个 activity 中的用户个人资料

How to set profile picture obtained from facebook login to user profile in another activity

我在我的应用程序中使用 facebook 登录。我正在使用 Profile class 来获取基本用户信息,例如姓名、个人资料图片。这是我用来更新登录 activity 中的 UI 的方法 updateUI() 的代码片段。

private void updateUI() {
        boolean enableButtons = AccessToken.getCurrentAccessToken() != null;
          Profile profile = Profile.getCurrentProfile();
        if (enableButtons && profile != null) {
            profilePictureView.setProfileId(profile.getId());
            Toast.makeText(login.this,"Login Success", Toast.LENGTH_SHORT).show();
            greeting.setText(profile.getName());
            url.setText(profile.getProfilePictureUri(60,60).toString());
        }
        else {
            profilePictureView.setProfileId(null);
            greeting.setText(null);
            url.setText(null);
        }
    }  

现在我想将个人资料图片传递给另一个 activity 并将其设置为圆形缩略图。我想知道该怎么做。这是我要设置图像的另一个 activity 中配置文件部分的代码。目前我已经在那里放置了一个 drawable 资源。

drawer.addProfile(
                new DrawerProfile()
                        .setId(1)
                        .setRoundedAvatar((BitmapDrawable) getResources().getDrawable(R.drawable.appeti))
                        .setBackground(getResources().getDrawable(R.drawable.ghewar))
                        .setName(getString(R.string.welcome))
                        .setDescription(name)
                        .setOnProfileClickListener(new DrawerProfile.OnProfileClickListener() {
                            @Override
                            public void onClick(DrawerProfile drawerProfile, long id) {
                                Toast.makeText(Home.this, "Clicked profile #" + id, Toast.LENGTH_SHORT).show();
                                Intent login = new Intent(getApplicationContext(),login.class);
                                startActivity(login);
}
})
);

我正在使用 github 的 MaterialDrawer 库在其他 activity 的导航抽屉中显示配置文件。我能想到的一种方法是 URL 个人资料图片,我可以从 url 文本字段中获取,如方法 updateUI() 所示,然后通过 intent 传递给另一个 [=26] =].但是我不知道如何使用这个 URL 在抽屉配置文件中设置缩略图。任何帮助表示赞赏。提前致谢。

我能想到的最简单的解决方案是您可以使用像 Picasso or Volley 这样的库从 url 中获取图像并将其直接加载到 imageview

代码将使用 Picasso 库

Picasso.with(context).load("Facebook_profile_picture_URL").into(imageView);

一行代码

关于 Volley 库,它需要先进行一些设置。