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.
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
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
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.
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:
Editar: No olvides configurar tu app en Google api console
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