由于Facebook受众群体网络广告(插页式广告),应用程序崩溃了 早些时候它在另一个应用程序中工作正常,现在这个问题 java.lang.IllegalStateException:广告已经开始
错误显示:
java.lang.IllegalStateException: ad already started
at com.facebook.ads.internal.DisplayAdController.b(Unknown Source)
at com.facebook.ads.InterstitialAd.show(Unknown Source)
at com.arham.csdevbin.healthybody.mFragment.DietFragment$5.onAdLoaded(DietFragment.java:221)
at com.facebook.ads.InterstitialAd$1.a(Unknown Source)
at com.facebook.ads.internal.DisplayAdController$11.onInterstitialAdLoaded(Unknown Source)
at com.facebook.ads.internal.adapters.l$2.c(Unknown Source)
at com.facebook.ads.internal.adapters.l$2.a(Unknown Source)
at com.facebook.ads.internal.c.b$1$2.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
这是广告代码........
public void loadInterstitialAd() {
interstitialAd = new com.facebook.ads.InterstitialAd(getActivity(), "962300780587295_962314293919277");
interstitialAd.setAdListener(new InterstitialAdListener() {
@Override
public void onInterstitialDisplayed(Ad ad) {
}
@Override
public void onInterstitialDismissed(Ad ad) {
}
@Override
public void onError(Ad ad, AdError adError) {
}
@Override
public void onAdLoaded(Ad ad) {
interstitialAd.show();
}
@Override
public void onAdClicked(Ad ad) {
}
@Override
public void onLoggingImpression(Ad ad) {
}
});
interstitialAd.loadAd();
}
我不知道为什么会出现这个错误。
加
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_diet, container, false);
loadInterstitialAd();
return view;
}
答案 0 :(得分:1)
我遇到了同样的问题。所以我向Facebook报告了错误,他们告诉我将Facebook Audience Network SDK升级到
com.facebook.android:audience-network-sdk:4.99.1
现在可以正常工作了。
答案 1 :(得分:-1)
试
# .----------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7)
# | | | | |
# * * * * * command to be executed
31 10 * * 3 sleep 10 && /file/to/run.py
覆盖另一种方法@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
loadInterstitialAd();
}