我在通过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广告。但调解是错误的。 问题是什么? 请让我知道如何解决它。