弹出窗口的Google Play游戏服务视图

时间:2014-10-30 04:56:26

标签: java android google-play-games

我刚为我的游戏整合了Google Play游戏服务。在日志中我看到一个警告说:

"10-29 23:13:29.559: W/PopupManager(6985): 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."

这是我应该担心的吗?谷歌的默认视图和布局对我来说没问题。此外,如果我按下主页按钮或进入排行榜活动中的设置,它会显示强制关闭 - 弹出窗口是否有查看该问题的原因?

1 个答案:

答案 0 :(得分:5)

这应该可以解决问题:

@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 为您提供视图的根元素,而无需知道其实际名称/类型/ ID。查看从当前活动中获取根视图

相关问题