Android Google Plus SDK: how to get callback on +1 button (PlusOneButton)

I added a +1 button in my Android app. I would like to add a callback to find out what happened after the user pressed the +1 button (did he confirm his +1 ?, did he interrupt? ...)

How can i do this?

Thanks!

+6
source share
1 answer

You can add a listener to check when the button is pressed, and then check the result of the activity.

static final int PLUS_ONE_REQUEST = 1; ... mPlusOneButton.setOnPlusOneClickListener(new PlusOneButton.OnPlusOneClickListener() { @Override public void onPlusOneClick(Intent intent) { //here you can handle the initial click //Start the activity to display the +1 confirmation dialog. startActivityForResult(intent, PLUS_ONE_REQUEST); } }); ... @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == PLUS_ONE_REQUEST) { switch(resultCode) { case RESULT_OK: //here the operation was successful break; case RESULT_CANCELED: //here the user backed out or failed break; } } } 

Sources: Click processing. Getting result from action.

I hope this is what you asked, and more importantly, that it was helpful.

0
source

Source: https://habr.com/ru/post/957482/


All Articles