【问题标题】:Adding a Google +1 button in Android App not working在 Android 应用中添加 Google +1 按钮不起作用
【发布时间】:2013-11-10 10:52:03
【问题描述】:

我花了很多时间尝试将这个东西放入我的应用程序中。 我不断收到“The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.” - 我也收到此消息,用于 google-play-services 包附带的 google 示例应用程序。 我已经按照这个问题的确切步骤进行操作:Adding a Google +1 button in Android App。从我所看到的情况来看,不再需要 PlusClient 了,因为 PlusOneButton 的构造函数不需要它。我还有什么需要做的吗??

在我投入更多时间之前,我想知道认为应该做的事情是否正确:

  • 此按钮的 URL 需要是 google play 应用页面的 URL: “https://play.google.com/store/apps/details?id=com.app.package”,如果用户按下这个 +1 按钮,这个页面的 +1 将会增加。

  • 如果用户按下这个 +1 按钮,如果他已经安装了 google play 应用程序,他就不需要再登录了。所以在他按下这个之后,只有按钮的颜色会改变,不会弹出任何东西。

  • 1234563 )

如果有人有一些答案,请帮忙。 谢谢。

【问题讨论】:

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


    【解决方案1】:
    1. 你可以像你说的那样使用play应用的url或者一些url来加账号,比如“http://plus.google.com/+Example

    2. 他不需要再次登录,但他会收到一个弹出窗口,通知他他 +1 你的网址

    3. 如果您想在弹出窗口关闭后在应用中执行某些操作,请使用请求代码并在 onActivityResult 处处理您想要的操作。

    例如(来自here):

    在布局中包含 PlusOneButton:

    <com.google.android.gms.plus.PlusOneButton
      xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
      android:id="@+id/plus_one_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      plus:size="standard"
      plus:annotation="inline" />
    

    将 PlusOneButton 分配给 Activity.onCreate 处理程序中的成员变量。

    mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
    

    每次活动在 Activity.onResume 处理程序中获得焦点时刷新 PlusOneButton 的状态。

    // The request code must be 0 or greater. You can use it at onActivityResult method
    private static final int PLUS_ONE_REQUEST_CODE = 0;
    
    protected void onResume() {
        super.onResume();
        // Refresh the state of the +1 button each time the activity receives focus.
        mPlusOneButton.initialize("http://plus.google.com/+Example", PLUS_ONE_REQUEST_CODE);
    }
    

    【讨论】:

    • 感谢您的回答。非常感谢显示按钮如何正确配置的 sn-p 代码。
    【解决方案2】:

    要添加加一按钮,首先您需要在开发者控制台中注册应用程序, 包括 google play lib,然后将 +1 按钮放在适当的位置。

    浏览这篇帖子http://www.feelzdroid.com/2014/09/google-plusone-1-button-in-android-application-integration-guide.html

    这从在开发者控制台中注册应用程序的基础知识到在应用程序中放置按钮的基础知识进行了简要说明。

    希望对你有帮助,有什么问题可以留言,对你有帮助。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多