Благодаря платформе Google+ для Android вы теперь можете встроить встроенную кнопку +1 в свое приложение для Android.
1) Сначала вам нужно инициализировать PlusClient
объект в вашей деятельности.
2) Включите кнопку 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" />
3) Назначьте PlusOneButton переменной-члену в вашем обработчике Activity.onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPlusClient = new PlusClient(this, this, this);
mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
}
4) Обновляйте состояние PlusOneButton каждый раз, когда действие получает фокус в вашем обработчике Activity.onResume.
protected void onResume() {
super.onResume();
// Refresh the state of the +1 button each time the activity receives focus.
mPlusOneButton.initialize(mPlusClient, URL);
}
Для получения дополнительной информации см. https://developers.google.com/+/mobile/android/#recommend_content_with_the_1_button