I added a +1 button in my Android app. I would like to add a callback in order to know what happened after the user clicked on the +1 button (did he validate its +1 ?, did he abort ? ...)
How can I do that ?
Thanks !
I added a +1 button in my Android app. I would like to add a callback in order to know what happened after the user clicked on the +1 button (did he validate its +1 ?, did he abort ? ...)
How can I do that ?
Thanks !
You can add a listener to check when the button is clicked and later 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: Handling the click Getting a result from an activity
I hope that this is what your were asking, and more importantly that this was helpful.
© 2022 - 2024 — McMap. All rights reserved.