android怎么样来允许添加至Facebook [英] android how to add permission to facebook

查看:254
本文介绍了android怎么样来允许添加至Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加权限读取电子邮件从Facebook的Andr​​oid SDK中。

i want to add permission to read email from the facebook android sdk.

    Session.openActiveSession(this, true, new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state,
                Exception exception) {
            // TODO Auto-generated method stub
            if (session.isOpened()) {
                // make request to the /me API
                Request.executeMeRequestAsync(session,
                        new Request.GraphUserCallback() {

                            @Override
                            public void onCompleted(GraphUser user,
                                    Response response) {
                                if (user != null) {
                                    et_firstName.setText(user
                                            .getFirstName());
                                    et_lastName.setText(user
                                            .getLastName());
                                    Log.e("data",
                                            user.asMap().get("email")
                                                    + "");
                                    URL image_value;
                                    try {
                                        image_value = new URL(
                                                "http://graph.facebook.com/"
                                                        + user.getId()
                                                        + "/picture");
                                        iv_profileImage
                                                .setImageBitmap(BitmapFactory
                                                        .decodeStream(image_value
                                                                .openConnection()
                                                                .getInputStream()));
                                    } catch (MalformedURLException e) {
                                        e.printStackTrace();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                } else {

                                }
                            }
                        });
            }
        }
    });

我曾尝试

我读了很多,这是可以做到用 loginbutton ,但我不希望使用loginbutton。

what i have tried

I read a lot that this can be done using loginbutton but i don't want to use loginbutton.

还我读,如果我不希望使用 logingbutton ,我必须使用 openfor 会议,但我不知道如何使用

also i read that if i don't want to use logingbutton, i have to use openfor session, but i didn't know how to use that

推荐答案

如果您使用的是LoginButton,使用:

If you use a LoginButton, use:

loginButton.setReadPermissions(Arrays.asList("email"));

如果您启动会话自己时,使用:

If you start the Session yourself, use:

session.openForRead(new Session.OpenRequest(this).setPermissions(Arrays.asList("email")));

请求/权限乐于助人的链接: https://developers.facebook.com/tool​​s/explorer/

在全成登录,尝试再次请求包括电子邮件域。

After successfull login, try the request again including the email field.

这篇关于android怎么样来允许添加至Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆