我创建了一个Android游戏,我正在使用横幅广告和插页式广告 1)横幅广告在玩游戏时显示,2)插页式广告显示当玩家最终赢得一个级别但我遇到的问题是admob插页式广告正在显示但是一个人无法点击它,它只显示在关卡端但用户无法点击它我尝试搜索但无法找到解决方案, 请帮忙 这些是游戏中广告代码的来源用法
活动文件:
public class APP extends Activity
{
private InterstitialAd interstitial;
}
public static void showInterAd(){
((APP)APP.ctx).showAd();
}
// BANNER AD
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ctx = this;
setVolumeControlStream(AudioManager.STREAM_MUSIC);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
// Create ad request.
AdRequest adRequest = new AdRequest.Builder().build();
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(adRequest);
}// INTERSTITIAL AD
public void showAd(){
((Activity)ctx).runOnUiThread(new Runnable() {
@Override
public void run() {
// Create the interstitial.
interstitial = new InterstitialAd(APP.this);
interstitial.setAdUnitId("ca-app-pub-ID");
AdRequest adRequest = new AdRequest.Builder().build();
interstitial.loadAd(adRequest);
// Set the AdListener.
interstitial.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
if (interstitial.isLoaded()) {
interstitial.show();
我在不同的文件中调用广告代码:
levelCompleted = true;
endOfGame = true;
soundManager.playSound(APP.SOUND_WON);
APP.showInterAd();
}
清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.XYZ"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:required="false" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:required="false" />
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"
android:required="false" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"
android:required="false" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<activity
android:name="com.xyz.APP"
android:alwaysRetainTaskState="true"
android:configChanges="orientation|keyboard"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.XYZ.GAME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>
答案 0 :(得分:1)
删除:
来自Manifest File的 android:launchMode="singleInstance"
。
答案 1 :(得分:0)
好的,你的代码有很多问题。我建议您首先关注https://developers.google.com/mobile-ads-sdk/docs/admob/advanced上的示例。
你真正需要修理的几件事情: