Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Pop Up is displayed when Calling Games.Achievements.unlock

My current Android game employs BaseGameActivity.

My game employs Achievements, which are getting unlocked when required.

However, I do not ALWAYS see the PopUps related to the unlock event.

I know the popup only appears when you first unlock the Achievement.

Some popups appear fine, others (from different screens within my game) never appear.

What do I have to do to Guarantee the popups appear?

I have a feeling its related to this WARNING:

W/PopupManager(10725): You have not specified a View to use as content view for popups.

Falling back to the Activity content view which may not work properly in future versions
of the API. 
Use setViewForPopups() to set your content view.

I have called setViewForPopups() from within the activity my popups do not display in, however, I have never seen them.

How do you call setViewForPopups() so that your entire application never sees the WARNING messages shown above?

like image 690
Hector Avatar asked Jul 11 '14 19:07

Hector


1 Answers

There has been some changes in recent update to play services framework. Use this instead so that you can see greeting popup and unlock popups as well.

GamesClient gamesClient = Games.getGamesClient(this, GoogleSignIn.getLastSignedInAccount(this));
gamesClient.setViewForPopups(findViewById(android.R.id.content));
gamesClient.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);

Don't forget to import as required like-

import android.view.Gravity;
import com.google.android.gms.games.GamesClient;
like image 55
Sajal Dutta Avatar answered Oct 19 '22 22:10

Sajal Dutta