【问题标题】:Android Google Plus SDK: how to get callback on the +1 button (PlusOneButton)Android Google Plus SDK:如何在 +1 按钮上获取回调 (PlusOneButton)
【发布时间】:2013-11-17 10:41:42
【问题描述】:

我在我的 Android 应用中添加了一个 +1 按钮。我想添加一个回调,以了解用户单击 +1 按钮后发生的情况(他是否验证了 +1 ?,他是否中止了?...)

我该怎么做?

谢谢!

【问题讨论】:

    标签: android api google-plus google-play-services google-plus-one


    【解决方案1】:

    您可以添加一个侦听器来检查按钮何时被单击,然后检查活动的结果。

    static final int PLUS_ONE_REQUEST = 1;
    ...
    mPlusOneButton.setOnPlusOneClickListener(new PlusOneButton.OnPlusOneClickListener() {
        @Override
        public void onPlusOneClick(Intent intent) {
    
            //here you can handle the initial click
    
            //Start the activity to display the +1 confirmation dialog.
            startActivityForResult(intent, PLUS_ONE_REQUEST);
        }
    });
    ...
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode == PLUS_ONE_REQUEST) {
            switch(resultCode) {
                case RESULT_OK:
                    //here the operation was successful
                    break;
                case RESULT_CANCELED:
                    //here the user backed out or failed
                    break;
            }
        }
    }
    

    来源: Handling the click Getting a result from an activity

    我希望这是您的要求,更重要的是,这对您有所帮助。

    【讨论】:

    • 你怎么称呼“显示+1确认对话框的活动”?这个确认对话框是什么样的?是带有登录/注销/撤销按钮的对话框吗?还是 Google Plus 对话框在用户 G+ 墙上发布内容?谢谢。
    • 此确认对话框验证用户是否已登录。+1 按钮不会显示确认警报,因为可以通过重新单击该按钮来撤消。
    猜你喜欢
    • 1970-01-01
    • 2013-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    相关资源
    最近更新 更多