Facebook FriendPicker not shown (Facebook Android SDK Tutorial “Show Friends” are not up to date?)

霸气de小男生 提交于 2019-12-12 11:44:50

问题


I recently downloaded facebook-android-sdk-3.8.0 and begun to develop an example-app with Facebook integration.

I'm following these tutorials on the Facebook Developers page: https://developers.facebook.com/docs/android/scrumptious

I have successfully implemented the first two parts, i.e. "Authenticate" and "Personalize". But now I'm totally stuck on the "Show Friends" tutorial (https://developers.facebook.com/docs/android/scrumptious/show-friends).

Step 2e works good, but from that to step 3c is not.

The problem is that the friends picker is not shown at all. When I touch the "With whom? Select friends" button, the activity is opened and I see the blue bar at the top with the title "Choose Friends" and the Done-button on the right. But the activity is otherwise white, i.e. without the list of friends.

By examining LogCat, I can't recognise any meaningful error or log messages.

I have read the tutorial through sentence by sentence for at least four times and compared to my implementation, and I just can't find the cause of why the friends picker is not shown. Have also tried to google for a cause and solution but without luck.

I would really appreciate if you can identify the problem and help me to solve this, so I can continue with the tutorial :)


回答1:


The resolution is request the permission for LoginButton default. Declarate the public global LoginButton in SplashFragment and setReadPermission(); for example:

private void showFragment(int fragmentIndex, boolean addToBackStack) {
        FragmentTransaction transaction = fm.beginTransaction();
        for (int i = 0; i < fragments.length; i++) {
            if (i == fragmentIndex) {
                transaction.show(fragments[i]);
                if(i==SPLASH){
                    SplashFragment sf=(SplashFragment)fragments[i];      sf.login.setReadPermissions(Arrays.asList("public_profile","user_friends"));
                    //Log.d("TEST","Permission Set");
                }
            } else {
                transaction.hide(fragments[i]);
            }
        }
        if (addToBackStack) {
            transaction.addToBackStack(null);
        }
        transaction.commit();
    }


来源:https://stackoverflow.com/questions/23553428/facebook-friendpicker-not-shown-facebook-android-sdk-tutorial-show-friends-ar

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