Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android和网站之间的Google Plus一键一致性_Android_Google Plus One - Fatal编程技术网

Android和网站之间的Google Plus一键一致性

Android和网站之间的Google Plus一键一致性,android,google-plus-one,Android,Google Plus One,我已经按照google play服务示例在我的Android应用程序中添加了一个PlusOneButton,加减功能目前运行良好。只是我遇到了一个问题,当用户通过他们的+1网站(在个人资料->+1中)删除plus项并返回应用程序时,plus状态不会在我的应用程序中更新,它将保持plus状态。(看起来Play store会将状态更改为un plus)。我不知道play store是怎么做的。有人能给我一些建议吗?还有没有办法像play store那样实现+1功能?不必显示弹出对话框 以下是我的代码

我已经按照google play服务示例在我的Android应用程序中添加了一个PlusOneButton,加减功能目前运行良好。只是我遇到了一个问题,当用户通过他们的+1网站(在个人资料->+1中)删除plus项并返回应用程序时,plus状态不会在我的应用程序中更新,它将保持plus状态。(看起来Play store会将状态更改为un plus)。我不知道play store是怎么做的。有人能给我一些建议吗?还有没有办法像play store那样实现+1功能?不必显示弹出对话框

以下是我的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.plustest);

    int errorCode = GooglePlusUtil.checkGooglePlusApp(this);
    if(errorCode != GooglePlusUtil.SUCCESS) {
        GooglePlusUtil.getErrorDialog(errorCode, this, 0).show();
    } else {
        // The +1 button does not require scopes.
        mPlusClient = new PlusClient.Builder(this, this, this)
             .clearScopes()
             .build();
    }

    /*
     * The {@link PlusOneButton} can be configured in code, but in this example we
     * have set the parameters in the layout.
     *
     * Example:
     * mPlusOneSmallButton.setAnnotation(PlusOneButton.ANNOTATION_INLINE);
     * mPlusOneSmallButton.setSize(PlusOneButton.SIZE_MEDIUM);
     */
    mPlusOneSmallButton = (PlusOneButton) findViewById(R.id.plus_one_small_button);
    mPlusOneMediumButton = (PlusOneButton) findViewById(R.id.plus_one_medium_button);
    mPlusOneTallButton = (PlusOneButton) findViewById(R.id.plus_one_tall_button);
    mPlusOneStandardButton = (PlusOneButton) findViewById(R.id.plus_one_standard_button);
    mPlusOneStandardButtonWithAnnotation = (PlusOneButton) findViewById(
         R.id.plus_one_standard_ann_button);

}


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


@Override
protected void onResume() {
    super.onResume();
    // Refresh the state of the +1 button each time we receive focus.
    mPlusOneSmallButton.initialize(mPlusClient, URL, PLUS_ONE_REQUEST_CODE);
    mPlusOneMediumButton.initialize(mPlusClient, URL, this);
    mPlusOneTallButton.initialize(mPlusClient, URL, PLUS_ONE_REQUEST_CODE);
    mPlusOneStandardButton.initialize(mPlusClient, URL, PLUS_ONE_REQUEST_CODE);
    mPlusOneStandardButtonWithAnnotation.initialize(mPlusClient, URL, PLUS_ONE_REQUEST_CODE);
}


@Override
protected void onStop() {
    super.onStop();
    mPlusClient.disconnect();
}


@Override
public void onClick(View v) {
}

@Override
public void onButtonClick(int id) {

}

@Override
public void onDashboardClick() {

}

@Override
public void onConnected(Bundle bundle) {
    String name = mPlusClient.getAccountName();
}

@Override
public void onDisconnected() {

}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    mConnectionResult = connectionResult;

    if(!mPlusClient.isConnected()) {
        try {
            mConnectionResult.startResolutionForResult(this, PLUS_ONE_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
            mConnectionResult = null;
            mPlusClient.connect();
        }
    }
}

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

@Override
public void onPlusOneClick(Intent intent) {
    if(!mPlusClient.isConnected()) {
        mPlusClient.connect();
    } else {
        startActivityForResult(intent, 0);
    }

}

我在SDK 13上注意到,当你+1你的网站时,它在应用程序中没有被考虑(可能是一种bug)。但是,当您在应用程序中输入+1时,会出现一个窗口:

  • 如果单击“确定”,请在网站上添加+1
  • 如果单击“取消”,请删除网站上的+1