小编Olg*_*lga的帖子

tagForChildDirectedTreatment(boolean) 已弃用

我正在尝试将库“com.google.android.gms:play-services-ads”从版本 17.2.0 更新到 18.1.1。我收到一条警告,说 builder.tagForChildDirectedTreatment(true) 方法已被弃用。

在文档(https://developers.google.com/android/reference/com/google/android/gms/ads/AdRequest.Builder)中,据说应该使用 setTagForChildDirectedTreatment(int) 代替。但是我找不到有关如何使用它的任何示例。文档 ( https://developers.google.com/admob/android/targeting ) 未更新。他们仍然使用不推荐使用的 tagForChildDirectedTreatment(true)。有人可以帮我吗?

这是我的代码:

private void loadAds() {
    MobileAds.initialize(this, getString(R.string.adMobAppId));
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getString(R.string.adMobUnitId));
    Bundle extras = new Bundle();
    extras.putBoolean("is_designed_for_families", true);
    AdRequest.Builder builder = new AdRequest.Builder()
            .addNetworkExtrasBundle(AdMobAdapter.class, extras);
    builder.tagForChildDirectedTreatment(true);
    mInterstitialAd.loadAd(builder.build());
    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {

            if (mInterstitialAd.isLoaded()) {
                mInterstitialAd.show();
            }

        }
    });
}
Run Code Online (Sandbox Code Playgroud)

java admob android-studio

10
推荐指数
1
解决办法
3073
查看次数

在 null 上调用了 getter 'userGestureInProgress'

我正在为儿童创建一个应用程序。它有菜单屏幕,您可以通过单击适当的按钮转到不同的游戏。游戏完成后,开始播放星星动画。动画完成后,我希望我的应用程序返回到菜单屏幕。这是问题所在。动画完成后,我收到此错误:The getter 'userGestureInProgress' was called on null.也没有堆栈跟踪,因此我无法确定此错误发生的确切位置。

这是我的代码:

class OddOneOutPage extends StatefulWidget {
 @override
 State<StatefulWidget> createState() {
 return OddOneOutPageState();
 }
}

class OddOneOutPageState extends State<OddOneOutPage>
with SingleTickerProviderStateMixin {
  Widget _pageContent;
  ValueNotifier<bool>_animationFinished;
  Particles particles;
  bool _gameFinished = false;

  @override
  void initState() {
    super.initState();
   _animationFinished = ValueNotifier(false);

   _animationFinished.addListener(() {
      if(_animationFinished.value) {
        Navigator.pop(context); // this line causes a problem
      }
   });

   particles = Particles(30, _animationFinished);
  }

  @override
  Widget build(BuildContext context) {
    Widget body;

  // some code to check if game is …
Run Code Online (Sandbox Code Playgroud)

dart flutter

7
推荐指数
1
解决办法
1170
查看次数

标签 统计

admob ×1

android-studio ×1

dart ×1

flutter ×1

java ×1