Java 谷歌+按钮集成…出了点问题

Java 谷歌+按钮集成…出了点问题,java,android,google-plus,Java,Android,Google Plus,我对Google+按钮集成有这个问题。logcat或force close中没有错误,但有些地方不正确。我添加了按钮,您可以在下面看到我的XML。当我离线的时候它是灰色的,当我在线的时候它是红白的,所以我想这很好。您还可以查看按钮的java代码。问题是,当我点击它时,它会打开一个带有我的google+名称的弹出窗口一秒钟,然后我得到一个错误,你可以在下面的屏幕截图上看到。我模糊了我的名字。这是屏幕: 和我的XML: <LinearLayout xmlns:android="http://s

我对Google+按钮集成有这个问题。logcat或force close中没有错误,但有些地方不正确。我添加了按钮,您可以在下面看到我的XML。当我离线的时候它是灰色的,当我在线的时候它是红白的,所以我想这很好。您还可以查看按钮的java代码。问题是,当我点击它时,它会打开一个带有我的google+名称的弹出窗口一秒钟,然后我得到一个错误,你可以在下面的屏幕截图上看到。我模糊了我的名字。这是屏幕:

和我的XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bac2k"
    android:gravity="center|top"
    android:orientation="vertical"
    tools:context=".Plusone" xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout
        android:id="@+id/la2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="visible" >

         <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="25dp"
        android:text="Click +1 button and tap OK"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <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"
        android:layout_marginBottom="20dp"
        plus:annotation="inline"
        plus:size="standard" >

    </com.google.android.gms.plus.PlusOneButton>

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="25dp"
        android:text="Or wait:"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>

</LinearLayout>
和我的java代码:

public class Plusone extends Activity implements ConnectionCallbacks, OnConnectionFailedListener {

Intent intent;
TextView licznik,title;
PendingIntent pintent;
int state;
private static final int PLUS_ONE_REQUEST_CODE = 0;
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
   private ProgressDialog mConnectionProgressDialog;
   private PlusClient mPlusClient;
   private ConnectionResult mConnectionResult;
   private PlusOneButton mPlusOneMediumButton;
   int sec;
   LinearLayout lay2;
   Handler han2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         mPlusClient = new PlusClient.Builder(this, this, this)
            .clearScopes()
            .build();
        setContentView(R.layout.plusone);
          mPlusOneMediumButton = (PlusOneButton) findViewById(R.id.plus_one_button);

        state=0;

         sec=15;
         licznik=(TextView)findViewById(R.id.textView1);
            lay2=(LinearLayout)findViewById(R.id.la2);
            title=(TextView)findViewById(R.id.textView2);

            if(state==1)
            {

                 lay2.setVisibility(View.GONE);
            }
            else
            {
                han2 = new Handler();
                han2.post(mUpdate);
            }
             mPlusOneMediumButton.initialize(mPlusClient, "https://market.android.com/details?id=us.mypackageame.game",new OnPlusOneClickListener() {
                   @Override
                   public void onPlusOneClick(Intent intent) {
                   // TODO Auto-generated method stub

                       state=1;
                      mPlusOneMediumButton.setVisibility(View.INVISIBLE);
                      title.setVisibility(View.GONE);
                       title.setVisibility(View.GONE);

                   startActivityForResult(intent, PLUS_ONE_REQUEST_CODE);
                   }
                   });

    }

             public void onConnectionFailed(ConnectionResult result) {
                 if (mConnectionProgressDialog.isShowing()) {
                         // The user clicked the sign-in button already. Start to resolve
                         // connection errors. Wait until onConnected() to dismiss the
                         // connection dialog.
                         if (result.hasResolution()) {
                                 try {
                                         result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                                 } catch (SendIntentException e) {
                                         mPlusClient.connect();
                                 }
                         }
                 }

                 // Save the intent so that we can start an activity when the user clicks
                 // the sign-in button.
                 mConnectionResult = result;
          }


         @Override
         public void onDisconnected() {
            // TODO Auto-generated method stub

         }
         @Override
         protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
            if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
                mConnectionResult = null;
                mPlusClient.connect();
            }

         }
         @Override
            protected void onStart() {
                super.onStart();
                mPlusClient.connect();
            }

            @Override
            protected void onStop() {
                super.onStop();
                mPlusClient.disconnect();
            }
            private Runnable mUpdate = new Runnable() {
                   public void run() {




                       han2.postDelayed(this, 1000);
                       sec=sec-1;
                       licznik.setText("Or wait: "+ Integer.toString(sec)+" seconds");
                    if (sec<=0)
                    {
                    han2.removeCallbacks(mUpdate);

                 lay2.setVisibility(View.GONE);

                 startActivity(new Intent("us.mypackageame.game.MENU"));
                 finish();

                    }
                    }

                };

            @Override
            public void onConnected() {
                String accountName = mPlusClient.getAccountName();
                  //  Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show();

            }
}

该版本的PlusOneButton初始值设定项是一个旧版本-请尝试确保您使用的是最新的Google Play服务,并从呼叫中删除PlusClient-请参阅

我也不确定这个URL是否能满足你的需要,也不确定在Play store中+1应用程序是否能满足你的需要,我认为它只会+1 URL本身,而URL本身可能不会显示在任何地方