我正在编写游戏并添加admob(版本6.4.1)。单击AD时,会出现两个问题,我不知道如何解决或调试。
我正在使用以下代码将admob添加到surfaceview。基本上,它在这里指的是其他帖子。
adView = new AdView(this, AdSize.SMART_BANNER, "My_ID");
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adView.setLayoutParams(lp);
RelativeLayout layout = new RelativeLayout(this);
layout.addView(new MySurfaceViewX(this));
layout.addView(adView);
adView.loadAd(new AdRequest());
setContentView(layout);
以下是logcat信息:
06-25 15:08:24.214: I/System.out(25294): Pause all Music
06-25 15:08:24.218: I/System.out(25294): onPause
06-25 15:08:25.007: I/Ads(25294): onPresentScreen()
06-25 15:08:25.007: I/System.out(25294): onPresentScreen
06-25 15:08:25.148: I/Ads(25294): onLeaveApplication()
06-25 15:08:25.148: I/System.out(25294): onLeaveApplication
06-25 15:08:25.273: I/System.out(25294): SurfaceDestoryed
06-25 15:08:25.402: I/System.out(25294): onStop (Game exit temperory and AD is running)
06-25 15:08:28.261: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.652: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:35.789: I/Ads(25294): onDismissScreen()
06-25 15:08:35.800: I/System.out(25294): onDismissScreen
06-25 15:08:35.960: I/System.out(25294): onRestart
06-25 15:08:35.960: I/System.out(25294): onResume
06-25 15:08:36.035: I/System.out(25294): SurfaceCreated
06-25 15:08:36.050: I/System.out(25294): surfaceChanged
06-25 15:08:39.722: I/System.out(25294): Pause all Music (when press "Back" key, it will go to background at here)
06-25 15:08:39.722: I/System.out(25294): onPause
06-25 15:08:40.164: I/System.out(25294): SurfaceDestoryed
06-25 15:08:41.285: W/IInputConnectionWrapper(25294): showStatusIcon on inactive InputConnection
06-25 15:08:42.621: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:42.621: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.621: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.625: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.625: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.625: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.636: I/System.out(25294): onStop
06-25 15:08:42.699: E/webview(25294): Error: WebView.destroy() called while still attached!
06-25 15:08:42.699: D/webviewglue(25294): nativeDestroy view: 0x52039c80
06-25 15:08:42.703: I/System.out(25294): onDestory
问题:
1)点击广告时,谷歌播放或资源管理器将运行。 Logcat将出现以下错误。
06-25 15:08:41.285: W/IInputConnectionWrapper(25294): showStatusIcon on inactive InputConnection
06-25 15:08:42.621: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:42.621: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
2)当按“返回”键并返回游戏时,如果再次按“返回”键,游戏将转到后台。它喜欢使用finish()或按“Home”键。游戏没有崩溃,再次按下图标后可以回电。
如果我没有点击AD,一切都运行正常。
我还发现如果它在模拟器上运行,它将不会有上面的ERROR。
拜托,谁可以帮助我?它让我疯了!
答案 0 :(得分:1)
我认为你可能允许你的EGL Surface和上下文被多个线程使用。 Android要求对给定上下文的所有对OpenGL ES的调用必须仅来自单个线程。本文详细解释: