UI components

+1 Button with Google Play Services

Alex Zhukovich 1 min read
+1 Button with Google Play Services
Table of Contents

Today, I'm talking about integrating Google's "+1" button to the Android application. This allows users to share your application in "Google+".

Firstly, you need to add a dependency to the gradle file.

dependencies {
    compile "com.google.android.gms:play-services:7.3.0"

Afterward, we need to add a "+1" button to your layout. A size of the PlusOneButton button may be standard, tall, small or medium. We need to change the size attribute for changing the size of the button.

Size of the "+1" button
        plus:annotation="none" />

The next step is updating an activity.

public class MainActivity extends AppCompatActivity {
    private static final int PLUS_ONE_REQUEST_CODE = 0;
    private static final String APP_URL = "https://play.google.com/store/apps/details?id=app_package";
    private PlusOneButton mPlusOneButton;
    private GoogleApiClient mGoogleApiClient;

    protected void onCreate(Bundle savedInstanceState) {
        mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
        mGoogleApiClient = new GoogleApiClient.Builder(this)

    protected void onResume() {
        mPlusOneButton.initialize(APP_URL, PLUS_ONE_REQUEST_CODE);

    protected void onStart() {
    protected void onStop() {

The last step is to change the app_package to your application package.

+1 button application demo

Mobile development with Alex

A blog about Android development & testing, Best Practices, Tips and Tricks

More from Mobile development with Alex
Jetpack Compose: Divider
Jetpack Compose

Jetpack Compose: Divider

This article covers using and customizing the “Dividers” components from the "Material 2" and "Material 3" libraries in the Jetpack Compose. In addition to that, we will explore the difference between implementation of the Divider, HorizontalDivider and VerticalDivider.
Alex Zhukovich 4 min read
Jetpack Compose: Switch
Jetpack Compose

Jetpack Compose: Switch

This article covers creating and customizing the "Switch" component in Jetpack Compose for enabling/disabling features. It explores differences between "Material" and "Material 3" libraries, and how to interact with and verify the Switch component's state in UI tests.
Alex Zhukovich 8 min read

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Mobile development with Alex.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.