我现在的安卓游戏使用的是BaseGameActivity。
我的游戏使用的是成就,在需要的时候会被解锁。
但是,我并不总是看到与解锁事件相关的PopUps。
我知道弹出只有在你第一次解锁的时候才会出现。
一些弹出窗口看起来很好,另一些(来自我游戏中的不同屏幕)从未出现过。
我要怎么做才能保证弹出窗口的出现?
我有一种感觉,它与这个警告有关:
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.我在弹出窗口不显示的活动中调用了setViewForPopups(),但是,我从未见过它们。
如何调用setViewForPopups(),使整个应用程序永远不会看到上面显示的警告消息?
发布于 2014-07-19 19:03:38
通过使用以下代码,我找到了一个解决方案
Games.setViewForPopups(getApiClient(), getWindow().getDecorView().findViewById(android.R.id.content));我可以让弹出式窗口显示出来。我现在有一个相关的问题。弹出式弹出物不会显示很长时间。
我认为这是因为我在这个活动中有一个定制的动画。
有什么方法可以增加弹出窗口的可见时间吗?
发布于 2019-12-20 04:25:05
最近对play服务框架的更新发生了一些变化。这样你就可以看到欢迎弹出窗口和解锁弹出窗口。
GamesClient gamesClient = Games.getGamesClient(this, GoogleSignIn.getLastSignedInAccount(this));
gamesClient.setViewForPopups(findViewById(android.R.id.content));
gamesClient.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);别忘了按要求进口-
import android.view.Gravity;
import com.google.android.gms.games.GamesClient;发布于 2015-04-11 22:07:04
这对我有用。
@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。
https://stackoverflow.com/questions/24705483
复制相似问题