2015-03-02 54 views
11

我使用official tutorial将Google加一个按钮添加到我的某个Android应用程序中。但加上一个按钮显示错误的计数。我在代码中所做的一切与本教程相同。我之前使用它从未得到这个愚蠢的错误。 现在我的应用程序已被推荐26次,所以加上一个按钮应该显示计数为“26”,但它显示“13”。Google Plus One按钮在Android应用程序中显示错误的计数(错误计数问题)

要包括在我的布局我用加号按钮:

<com.google.android.gms.plus.PlusOneButton 
       android:id="@+id/plus_one_button" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="@dimen/drawer_list_item_padding_left" 
       plus:annotation="inline" 
       plus:size="standard" 
       android:layout_marginBottom="@dimen/drawer_textview_paddingtopbottom" 
       android:layout_marginTop="@dimen/drawer_textview_paddingtopbottom" /> 

要分配按钮成员变量i用于:

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

如所建议的我使用初始化它在我的活动的onResume方法下面的代码:

mPlusOneButton.initialize(APP_URL, PLUS_ONE_REQUEST_CODE); 

这里APP_URL是我的应用程序的谷歌播放网页的网址, PLUS_ONE_REQUEST_CODE是我用它作为0的活动请求代码。

有什么建议吗?提前致谢。


在我的情况下,经过几天后,它显示出正确的g +计数本身。我没有在我的代码中进行任何更改,因为我确信我的代码根据文档是正确的。为什么我得到那个令人讨厌的延迟?我不知道,也许它与谷歌服务器和更新有关。

+0

'我用它从未得到这个愚蠢的error' - >请张贴产生错误的结果代码。如果它第一次工作,可能是你做错了什么,这会导致错误的结果。 – iRuth 2015-03-02 18:23:18

+0

@iRuth发布了我的代码。 – AnEnthusiast 2015-03-02 18:47:28

+0

布局文件中的'PlusOneButton'没有这行 - >'xmlns:plus =“http://schemas.android.com/apk/lib/com.google.android.gms.plus”'。你可以添加它,看看它是否有任何区别? – iRuth 2015-03-02 18:57:03

回答

2

我最好的猜测是:

  1. 上有APP_URL录入错误。在某些时候发生在每个人身上
  2. 我不知道这是否是一个因素。应用版本号与Google Play商店中的版本号不同。因此,它返回错误的+1计数

干杯