【问题标题】:how can I get my facebook friends profile photo at a time when i give a userid in android? [closed]当我在 android 中提供用户 ID 时,如何获取我的 facebook 朋友个人资料照片? [关闭]
【发布时间】:2012-10-03 09:31:41
【问题描述】:

在我的主布局中,有一个编辑文本和一个搜索按钮。当我在用用户 ID 填充文本字段后单击按钮时,它将显示相应用户 ID 的个人资料照片。 有人帮我吗?

【问题讨论】:

  • 到目前为止你做了什么?你的实际问题是什么?

标签: android facebook android-intent android-activity profile


【解决方案1】:

首先,它确实是一种奇怪的方式(输入用户ID,我怎么知道任何人的用户ID)......最好先获取您的朋友列表,然后任何朋友节目的onClick()显示图片。

无论如何,根据您的问题,您需要发送这样的查询

Bundle paramsFriends = new Bundle();
        paramsFriends.putString("method", "fql.query");
        paramsFriends.putString("query", Constants.QUERY_FRIENDS);



        /**
         * Show the Progress Bar
         */
        mProgressBar = new ProgressDialog(this);
        mProgressBar.setCancelable(true);
        mProgressBar.setMessage("Getting Friend List...");
        mProgressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressBar.setProgress(0);
        mProgressBar.setMax(100);
        mProgressBar.show();

        // The fourth param is like an id (state) to distinguish among
        // different requests
        mAsyncRunner.request(null, paramsFriends, this,
                Constants.QUERY_FRIENDS);

`

然后(注意:- 你的活动必须实现 RequestListener)在 onComplete() 方法中执行:-

public void onComplete(String response, Object state) {

    Log.v("  FQLRequestListener = ", "onComplete()");

    // friend list
    if (state.equals(Constants.QUERY_FRIENDS)) {

        Log.v("response", "" + response);
        Log.v("state", "" + state);

        Log.v("Display ", "Goto the new Activity to show FRIEND LIST");

        if (response != null) {
mProgressBar.dismiss();
        // response is the JSON respone
        // parse it to get the url of the image
        // download the pic from the url
        // then show it where ever you want
        }
    }
}

最后确认一下

Constants.QUERY_FRIENDS = "SELECT uid, name,username,sex,pic_small FROM user WHERE  uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";

这将为您提供整个朋友列表,只需将 onItemClickListener() 添加到您的列表中并相应地解析 json 响应以显示正确的图片。

希望解释有用....

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-19
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 2011-10-12
    相关资源
    最近更新 更多