Question

I used the following code to get my facebook user profile, the problem is , when I trigger the newMeRequest, it never response.

The session is already opened and I have also add the internet permission at manifest.xml, how to fix it ? Thanks for helping

public class ProfileFragment extends Fragment {

private View rootView;
private ImageView profilePic;
private Context ctx;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    ctx = getActivity();

    rootView = inflater.inflate(R.layout.profile, container, false);
    profilePic = (ImageView) rootView.findViewById(R.id.profile_pic);

    Session session = Session.getActiveSession();

    if (session.isOpened()) {
        Log.d("test1","success 123");
        Request.newMeRequest(session, new MeReqCallback());
    } else {
        Log.d("test1","fail 123");
    }

    return rootView;
}

private class MeReqCallback implements GraphUserCallback {
    @Override
    public void onCompleted(GraphUser user, Response response) {
        Log.d("test1",response.getError().getErrorMessage());
        new ImageLoader(ctx).execute(profilePic,"https://graph.facebook.com/"+ user.getId() +"/picture");
    }       
}

After logging, it fall into success 123, but it even did not fall into the onCompleted function , that means even no error message logged.

Thanks

Was it helpful?

Solution

You didn't actually execute the request. Add .executeAsync() on the end of your request definition.

OTHER TIPS

This is the same problem to which I answered here (app crash when try get user photo by Facebook iOS Graph API with app-scoped user id) yesterday.

Requesting /me/picture results in a http 304 redirect, and apparently ImageLoader() can't handle redirects the way you're using it currently.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top