Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a Google +1 button in Android App

I was just wondering if there was anyway to add a Google +1 button inside my Android app. I have seen a +1 on the Android Market so I would think there would be some way to do this.

like image 784
Emil Davtyan Avatar asked Jan 12 '12 22:01

Emil Davtyan


People also ask

How to add link button in android studio?

Create a String (named hyperlink) in string. xml and give its value like link and then set property android:setText="@string/hyperlink" to Button.


1 Answers

With the Google+ platform for Android, you are now able to integrate a native +1 button in your Android app.

1) You first need to initialize the PlusClient object in your Activity.

2) Include the PlusOneButton in your layout:

    <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) Assign the PlusOneButton to a member variable in your Activity.onCreate handler.

@Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     mPlusClient = new PlusClient(this, this, this);     mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button); } 

4) Refresh the PlusOneButton's state each time the activity receives focus in your Activity.onResume handler.

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

For more information, see https://developers.google.com/+/mobile/android/#recommend_content_with_the_1_button

like image 118
Chirag Shah Avatar answered Oct 04 '22 11:10

Chirag Shah