У меня проблемы с отображением моего изображения и имени на Facebook. Я не могу понять, как это сделать. Моя кнопка входа в Facebook работает отлично.Имя и изображение профиля из Facebook в приложение для Android
У меня эта ошибка: profilePictureView.setProfileId (profile.getId()); Ошибка NULL
public class Profile extends Activity {
/**
* Called when the activity is first created.
*/
WebView web;
ArrayList<NavigationDrawerItem> listItems;
DrawerLayout drawerLayout;
ActionBarDrawerToggle drawerToggle;
ListView list;
private CallbackManager callbackManager;
private ProfilePictureView profilePictureView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_profile);
callbackManager = CallbackManager.Factory.create();
LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions("public_profile", "email", "user_friends");
final ProfilePictureView profilePictureView = (ProfilePictureView) findViewById(R.id.profilepic);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
AccessToken accessToken = loginResult.getAccessToken();
com.facebook.Profile profile = com.facebook.Profile.getCurrentProfile();
profilePictureView.setProfileId(profile.getId());
Intent i = new Intent(Profile.this, Profile.class);
startActivity(i);
System.out.print("Logged in");
}
public final void getProfileId(){
Log.i("profileId", "Your profileId");
}
public final void setProfileId(String profileId) {
Log.i("profileId", "Your profileID");
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
Log.i("Error", "Error");
}
});
В моем XML-файле отсутствует изображение пользователя. Но не мое.
<com.facebook.login.widget.ProfilePictureView
android:id="@+id/welcome_profile_pic"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
facebook:preset_size="small" />
Устранено внутреннее намерение внутри: onSuccess – datasmurfen