Google Play 서비스 샘플을 따라 Android 앱에 PlusOneButton을 추가 했으므로 지금까지 더하기 및 빼기 기능이 제대로 작동합니다. 사용자가 +1 웹 사이트 (프로필 -> +1)에서 플러스 항목을 삭제하고 앱으로 돌아 가면 플러스 상태가 내 앱에서 업데이트되지 않고 플러스 상태로 유지됩니다. Play 스토어와 같은 모양은 상태를 취소되지 않은 상태로 변경합니다. 나는 놀이 가게가 어떻게되었는지 전혀 모른다. 누구든지 나에게 제안을 줄 수 있니? 또한 플레이 스토어처럼 +1 기능을 구현할 수있는 방법이 있습니까? 팝업 대화 상자를 표시하지 않아도됩니다. 내가 SDK (13)에 주목 무엇Google Plus One 버튼 Android와 웹 사이트 간의 일관성 유지
@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);
}
}