Agregar un botón de Google + 1 en la aplicación Android


Me preguntaba si había de todos modos para agregar un botón de Google +1 dentro de mi aplicación para Android. He visto un + 1 en el Android Market, así que creo que habría alguna manera de hacer esto.

Author: Kara, 2012-01-13

4 answers

Con la plataforma Google+ para Android, ahora puede integrar un botón nativo +1 en su aplicación Android.

1) Primero necesitas inicializar el objeto PlusClient en tu Actividad.

2) Incluya el PlusOneButton en su diseño:

    <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) Asigne el PlusOneButton a una variable miembro en su Actividad.Controlador de 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) Actualiza el estado del PlusOneButton cada vez que la actividad reciba el foco en tu Actividad.onResume handler.

protected void onResume() {
    super.onResume();
    // Refresh the state of the +1 button each time the activity receives focus.
    mPlusOneButton.initialize(mPlusClient, URL);
}

Para más información, ver https://developers.google.com/ + /mobile / android / #recommend_content_with_the_1_button

 23
Author: Chirag Shah,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-02-08 19:28:05

La respuesta aceptada está desactualizada....

XML:

<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" />

Actividad:

// The request code must be 0 or greater.

    private static final int PLUS_ONE_REQUEST_CODE = 0;

protected void onResume() {
    super.onResume();
    // Refresh the state of the +1 button each time the activity receives focus.
    mPlusOneButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
}

E incluso antes de que el barbecho este enlace:

Https://developers.google.com/+/móvil/android/getting-started

 10
Author: Jesus Dimrix,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-05-01 13:03:07

Para agregar google plus one, primero debe habilitar la API en developer console, luego registrar su aplicación con el nombre del paquete y luego incluirla en su aplicación.

Aquí está el ejemplo completo con una explicación detallada.

Http://www.feelzdroid.com/2014/09/google-plusone-1-button-in-android-application-integration-guide.html

 2
Author: Naruto,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-23 05:11:44

Con el nuevo android Studio(2.2.2 eso es lo que estoy usando) puedes hacerlo más fácilmente. Hay una función incorporada para crear fragmentos con el botón + 1. Puede usar el código de diseño o inicialización para PlusOneButton en una actividad o en cualquier lugar que desee. Compruebe la siguiente imagen: introduzca la descripción de la imagen aquí

Editar: No olvides configurar tu app en Google api console

 1
Author: Alvi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-22 05:35:10