4

i was trying to integrate G+ button in ma app.The G+ buttons grayed out.and its not counting.how to turns red ?

          public class HomeActivity extends SherlockActivity implements ConnectionCallbacks, OnConnectionFailedListener{

private static final String URL = "https://play.google.com/store/apps/details?id=com.phoneix.allu";
private static final int PLUS_ONE_REQUEST_CODE = 0;
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;

private ProgressDialog mConnectionProgressDialog;
private PlusClient mPlusClient;
private ConnectionResult mConnectionResult;
private PlusOneButton mPlusOneStandardButton;

@Override
public void onCreate(Bundle pBundle) {
    super.onCreate(pBundle);
   setContentView(R.layout.dashboard);

    mPlusOneStandardButton = (PlusOneButton) findViewById(R.id.plus_one_standard_button);


    mPlusClient = new PlusClient.Builder(this, this, this)

            .build();


}

@Override
public void onDestroy() {
    if (adView != null) {
        adView.destroy();
    }
    super.onDestroy();
}
@Override
protected void onResume() {
    super.onResume();
    // Refresh the state of the +1 button each time we receive focus.

    mPlusOneStandardButton.initialize(URL, PLUS_ONE_REQUEST_CODE);

}

@Override
public void onDisconnected() {
    // Nothing to do.
}
@Override
public void onConnectionFailed(ConnectionResult result) {
       if (mConnectionProgressDialog.isShowing()) {
               // The user clicked the sign-in button already. Start to resolve
               // connection errors. Wait until onConnected() to dismiss the
               // connection dialog.
               if (result.hasResolution()) {
                       try {
                               result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                       } catch (SendIntentException e) {
                               mPlusClient.connect();
                       }
               }
       }

       // Save the intent so that we can start an activity when the user clicks
       // the sign-in button.
       mConnectionResult = result;
}

public void onConnected(Bundle connectionHint) {
    mPlusOneStandardButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
        mConnectionResult = null;
        mPlusClient.connect();
    }
}

}

Asthme
  • 5,163
  • 6
  • 47
  • 65
  • its happening also to me in my app i also added G+ it is also greyed yesterday and today itself. I think it might be googleplayservice encountered problem. – Nitin Misra Nov 07 '13 at 05:19
  • @NitinMisra oh ok let me know when its working,if i know first i will let u know – Asthme Nov 07 '13 at 05:20

3 Answers3

0

Try out this:

In xml file:

    <com.google.android.gms.common.SignInButton
        android:id="@+id/sign_in_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="92dp" >
    </com.google.android.gms.common.SignInButton>

</RelativeLayout>

In your activity get that button:

    @Override
    public void onCreate(Bundle pBundle) {
    super.onCreate(pBundle);
    setContentView(R.layout.dashboard);

    findViewById(R.id.sign_in_button).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick
                    (View v) {
                        Intent i = new Intent(getApplicationContext(),YourActivity.class);
                        startActivity(i);
                    }
                });
}
Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138
  • what is Youractivity.class? should i sign into my app? – Asthme Nov 07 '13 at 05:28
  • That is which activity you are going to start.Here you need to mention your SignInActivity.In that you need to write logic for sign in to your app. – Shailendra Madda Nov 07 '13 at 05:30
  • Is your G+ button turned to red, let me know? – Shailendra Madda Nov 07 '13 at 05:33
  • some app has not sign in buttons ,they are getting default gmail address and automatically signed in.is it possible? – Asthme Nov 07 '13 at 06:06
  • welcome :), Are you want to directly go to sign in page with our performing on button click action when open the app? – Shailendra Madda Nov 07 '13 at 09:43
  • hey if person have multiple accounts,it will popup in dialog box.and when ever open the app,it will be popup,its wrong approach,when sign in to google play,it asks permissions(like post on ur timeline something..etc),For G+1 no permissons needed – Asthme Nov 07 '13 at 12:03
  • @DivyaRamakrishnan I think you are wrong about permissions. They do need GET_ACCOUNTS permissions...at least they used to.. – Amel Jose Nov 08 '13 at 17:15
  • I have the same problem in my apps with +1 buttons(grayed out)...Did you find a fix for this...Do we really have to write code to sign the user in?? – Amel Jose Nov 08 '13 at 17:17
  • @AmelJose i was not talking about permissions.i was taking about G+ permissions like post link in my timeline,share to my circles.i have added permissions.i think the problem in Google play service sdk,but i don't know how to fix.still having grayed out problem.. – Asthme Nov 09 '13 at 07:10
  • @DivyaRamakrishnan Oh i got it...but they are asking if they should recommend it in his/her circles,which is not there in other web based +1 buttons.. – Amel Jose Nov 10 '13 at 09:35
0

The problem is with the latest update of google play services. Once I uninstalled all updates of google play services from app's settings,all +1 buttons are showing up fine. Let's hope google will fix their update.

Amel Jose
  • 873
  • 2
  • 9
  • 22
0

The new Google Play update changed the interface of the plusOne button, hence breaking all plusOne button based on the "old" Google play service SDK. If you checkout their samples, you'll discover they have changed the interface for the plusOnButton.initialize, which no longer takes a "plusOneClient", but a URL.

To fix, download the latest (v13) Google Play Services using your "Android SDK Manager", and import it back to your project.

Guy
  • 12,250
  • 6
  • 53
  • 70