私はゲームを書いていて、admob (バージョン 6.4.1) を追加しています。AD をクリックすると、2 つの問題が発生し、解決方法やデバッグ方法がわかりません。
次のコードを使用して、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) AD をクリックすると、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() を使用するか、「ホーム」キーを押すのが好きです。ゲームはクラッシュせず、アイコンをもう一度押すとコールバックできます。
AD をクリックしていなければ、すべて正常に動作しています。
また、エミュレータで実行すると、上記のエラーが発生しないこともわかりました。
誰が私を助けてくれますか? それは私を夢中にさせます!