Failed to load Google +1 button when canceling button

I implement google plus one button, and it works fine when I press the +1 button and then click OK . But when I press the UNDO button, the +1 button is not available. If I clear the application data from the settings, it will start working properly, otherwise the +1 button will remain gray. Is this some kind of mistake or is there some solution to this problem? Below is the code I'm using.
In onCreate:

mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button); mPlusOneButton.setOnPlusOneClickListener(new PlusOneButton.OnPlusOneClickListener() { @Override public void onPlusOneClick(Intent intent) { try { startActivityForResult(intent, 0); }catch (NullPointerException e){ } } }); 

In onResume:

 mPlusOneButton.initialize(URL, PLUS_ONE_REQUEST_CODE); 

AND:

  @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data); if (resultCode == -1) { // OK or SHARE System.out.println("OK or SHARE"); mPlusOneButton.setIntent(null); } else { //UNDO System.out.println("UNDO"); } } 
+5
source share

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


All Articles