【发布时间】:2020-10-31 00:38:46
【问题描述】:
我正在尝试在打开或加载片段之前显示测试插页式广告。我的片段是从其他片段中调用的,我将测试广告的代码放在片段的 onCreateView() 中,我想在其打开之前放置广告,但实际上在显示(打开)该片段之前没有出现广告,而相同的代码正在工作并在 Ad 放置在同一片段类的 onResume() 内时显示 Ad。目标 API 16-30。任何帮助将不胜感激。
代码sn-p:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
查看 viewCalc2d=inflater.inflate(R.layout.fragment_calc2d, container, false);
mInterstitialAd = new InterstitialAd(getActivity().getBaseContext());
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.show();
// 做点什么
}
【问题讨论】:
-
兄弟,它需要先加载您的广告,然后您可以在片段开始时显示添加
-
就我而言,加载广告的正确位置是什么?展示广告的正确位置是什么?你的意思是我必须在 MainAactivity 的 onCreate() 中加载广告,然后在片段的 onCreatView 中显示它?
-
检查我的答案
标签: android interstitial