我在通过 AdMob 中介展示奖励(视频)广告时遇到了麻烦。
我所做的只是以下。
(1) 添加InMobi的库
InMobi-6.0.4.jar
libadapterinmobi.jar
(2) 在MainActivity中添加如下代码。
@Override
protected void onResume() {
super.onResume();
if (globals.adFlag == 1) {
// 2017.01.16 Add by Kazuhiko
// Show the Video Ads
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener()
{
@Override
public void onRewardedVideoAdLoaded()
{
Toast.makeText(MainActivity.this, "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdOpened()
{
Toast.makeText(MainActivity.this, "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoStarted()
{
Toast.makeText(MainActivity.this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdClosed()
{
Toast.makeText(MainActivity.this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
// Preload the next video ad.
loadRewardedVideoAd();
}
@Override
public void onRewarded(RewardItem rewardItem)
{
}
@Override
public void onRewardedVideoAdLeftApplication()
{
Toast.makeText(MainActivity.this, "onRewardedVideoAdLeftApplication", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdFailedToLoad(int i)
{
Toast.makeText(MainActivity.this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}
});
loadRewardedVideoAd();
mRewardedVideoAd.show();
this.setVisible(true);
globals.adFlag = 0;
}
}
private void loadRewardedVideoAd() {
AdRequest adRewardRequest = new AdRequest.Builder()
.build();
mRewardedVideoAd.loadAd(globals.ADMOB_VDO, adRewardRequest );
}
(3) 在AndroidManifest.xml 中添加以下行
<activity
android:name="com.inmobi.rendering.InMobiAdActivity"
android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize"
android:hardwareAccelerated="true" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
(4) 在 app.gradle 中添加以下行
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.android.support:multidex:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:25.0.0'
我的应用可以展示 Google 广告。但是调解是有问题的。问题是什么?请让我知道我该如何解决它。