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.

  • Android SeekBar setProgress is causing my MediaPlayer to skip
  • Error: Could not find com.google.gms:google-services:1.0. when adding google service plugin in build.gradle in android studio
  • Android Library Project with React Native
  • How to check programmatically if an application is installed or not in Android?
  • How to read barcodes with the camera on Android?
  • How to perform Auto crop for document Recognize image using camera?
  • 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 differnt 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 you entire application nevers sees the WARNING messages shown above?

    Related posts:

    Listening for keywords at all times, like “Ok google” on 4.4
    How to draw with a default Android font on a Canvas?
    Check if AnimatorSet has finished animation?
    How to fix INSTALL_PARSE_FAILED_MANIFEST_MALFORMED in my android application
    Can someone provide a good explanation of Dagger 2?
    Whitespace below CoordinatorLayout in DrawerLayout
  • scrolling in listview with different cell height
  • What is the difference between “px”, “dip”, “dp” and “sp” on Android?
  • Add transition to an AnimationDrawable
  • why is my pbkdf2 implementation so slow (vs. SQLCipher)?
  • Is there any way use new DrawerLayout with ActionBarSharlock?
  • Getting error: “bad read of inttemp!” when training a new font in Tesseract 2
  • 2 Solutions collect form web for “No Pop Up is displayed when Calling Games.Achievements.unlock”

    i have found a solution, by using this code

            Games.setViewForPopups(getApiClient(), getWindow().getDecorView().findViewById(android.R.id.content));
    

    i can get popups to show. I now have a related issue. The popup doesnt display for very long.

    I think this is due to the fact i have a custom animation into this activity.

    Is there any way to increase how long a popup is visible?

    This worked for me.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate");
    
        setContentView(R.layout.activity_main);
    
        // Create the Google API Client with access to Plus, Games and Drive
        // Also set the view for popups
        mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext())
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
                .addApi(Games.API).addScope(Games.SCOPE_GAMES)
                .addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER)
                .setViewForPopups(findViewById(android.R.id.content))
                .build();
    
    }
    

    android.R.id.content gives you the root element of a view, without having to know its actual name/type/ID. Check out Get root view from current activity

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.