Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 单击admob';s广告_Android_Admob - Fatal编程技术网

Android 单击admob';s广告

Android 单击admob';s广告,android,admob,Android,Admob,我正在编写一个游戏并添加admob(版本6.4.1)。当点击广告,它将有两个问题,我不知道如何解决或调试 我使用以下代码将admob添加到surfaceview。基本上,它指的是这里的其他帖子 adView = new AdView(this, AdSize.SMART_BANNER, "My_ID"); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutPa

我正在编写一个游戏并添加admob(版本6.4.1)。当点击广告,它将有两个问题,我不知道如何解决或调试

我使用以下代码将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) 当广告点击时,google play或explorer将运行。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”键。游戏不会崩溃,再次按下图标后可以回调

如果我没有点击广告,一切正常

我还发现,如果它在emulator上运行,就不会出现上述错误


请问,谁能帮我?这让我发疯

我认为您可能允许多个线程使用EGL表面和上下文。Android要求针对给定上下文对OpenGL ES的所有调用只能来自单个线程。本文详细说明:


我认为您可能允许多个线程使用EGL表面和上下文。Android要求针对给定上下文对OpenGL ES的所有调用只能来自单个线程。本文详细说明:


但我的游戏不是3D游戏,它会使用openGL吗?由于ICS版本,Android默认使用openGL ES 2.0。既然你说它可以在AVD模拟器上运行,那么问题可能是你设备上的OpenGL ES或EGL驱动程序有bug。什么是设备?试试另一个。极光2有什么类型的GPU?它比三星好用吗?如果是这样的话,我想你的问题可能是三星的驱动程序有问题。但我的游戏不是3D游戏,它会使用openGL吗?由于ICS版本,Android默认使用openGL ES 2.0。既然你说它可以在AVD模拟器上运行,那么问题可能是你设备上的OpenGL ES或EGL驱动程序有bug。什么是设备?试试另一个。极光2有什么类型的GPU?它比三星好用吗?如果是这样的话,我认为你的问题可能是三星的驱动程序有缺陷。