本文整理汇总了Java中com.google.android.gms.ads.doubleclick.PublisherInterstitialAd.setAdListener方法的典型用法代码示例。如果您正苦于以下问题:Java PublisherInterstitialAd.setAdListener方法的具体用法?Java PublisherInterstitialAd.setAdListener怎么用?Java PublisherInterstitialAd.setAdListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.ads.doubleclick.PublisherInterstitialAd
的用法示例。
在下文中一共展示了PublisherInterstitialAd.setAdListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
root = inflater.inflate(R.layout.fragment_interstitial, null);
// interstitial set up
mPublisherInterstitialAd = new PublisherInterstitialAd(getContext());
mPublisherInterstitialAd.setAdUnitId(Constants.DFP_INTERSTITIAL_ADUNIT_ID_FULLSCREEN);
mPublisherInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int i) {
super.onAdFailedToLoad(i);
if (i == AdRequest.ERROR_CODE_INTERNAL_ERROR) {
LogUtil.e("DFP", "Interstitial Ad failed to load internal error");
} else if (i == AdRequest.ERROR_CODE_INVALID_REQUEST) {
LogUtil.e("DFP", "Interstitial Ad failed to load internal error");
} else if (i == AdRequest.ERROR_CODE_NETWORK_ERROR) {
LogUtil.e("DFP", "Interstitial Ad failed to load network error");
} else if (i == AdRequest.ERROR_CODE_NO_FILL) {
LogUtil.e("DFP", "Interstitial Ad failed to load no fill");
}
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
mPublisherInterstitialAd.show();
}
});
request = new PublisherAdRequest.Builder().build();
Button btnLoad = (Button) root.findViewById(R.id.loadInterstitial);
btnLoad.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loadInterstitial(v);
}
});
return root;
}
示例2: getPopup
import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
private void getPopup(String adCode){
final PublisherInterstitialAd interstitialAd = new PublisherInterstitialAd(getActivity());
interstitialAd.setAdUnitId(adCode);
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
}
@Override
public void onAdLoaded() {
interstitialAd.show();
}
@Override
public void onAdFailedToLoad(int errorCode) {
}
@Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
}
@Override
public void onAdOpened() {
super.onAdOpened();
}
});
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
interstitialAd.loadAd(adRequest);
}
示例3: onCreate
import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
// Create the InterstitialAd and set the adUnitId.
mInterstitialAd = new PublisherInterstitialAd(this);
// Defined in res/values/strings.xml
mInterstitialAd.setAdUnitId(getString(R.string.ad_unit_id));
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
startGame();
}
@Override
public void onAdLoaded() {
mAdIsLoading = false;
}
@Override
public void onAdFailedToLoad(int errorCode) {
mAdIsLoading = false;
}
});
// Create the "retry" button, which tries to show an interstitial between game plays.
mRetryButton = findViewById(R.id.retry_button);
mRetryButton.setVisibility(View.INVISIBLE);
mRetryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showInterstitial();
}
});
startGame();
}
示例4: requestAd
import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
@Override
public void requestAd(MediatedInterstitialAdViewController mIC, Activity activity,
String parameter, String adUnitId, TargetingParameters targetingParameters) {
adListener = new GooglePlayAdListener(mIC, super.getClass().getSimpleName());
adListener.printToClog(String.format(" - requesting an ad: [%s, %s]", parameter, adUnitId));
interstitialAd = new PublisherInterstitialAd(activity);
interstitialAd.setAdUnitId(adUnitId);
interstitialAd.setAdListener(adListener);
interstitialAd.loadAd(buildRequest(targetingParameters));
}