How can I ensure admob will appear in my app

后端 未结 2 1066
有刺的猬
有刺的猬 2021-01-25 12:18

As we know, google requires us to use test device and test ad unit id, when we develop the app. However, I want to know that if there exists anyway that I can see the real ad, b

相关标签:
2条回答
  • 2021-01-25 12:45

    You can use AdListener and monitor why it is not showing ads . Remember if you have created fresh ad units then it will take some time or few hours to arrange live ads for it . If test ads are showing and you have valid ad unit id and also your app has not violated any policy then you are good to go (You will be emailed if your app have a policy issue) . Ads will be shown when availabe.

    AdView adView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest1 = new AdRequest.Builder().build();
    adView.loadAd(adRequest1);
    adView.setAdListener(new AdListener() {
      @Override
      public void onAdLoaded() {
        // Code to be executed when an ad finishes loading.
        Log.i("Ads", "onAdLoaded");
      }
    
      @Override
      public void onAdFailedToLoad(int errorCode) {
        // Code to be executed when an ad request fails.
    
    
        switch (errorCode){
          case AdRequest.ERROR_CODE_INTERNAL_ERROR:
            Toast.makeText(PlayListsActivity.this,"onAdFailedToLoad banner ERROR_CODE_INTERNAL_ERROR",Toast.LENGTH_SHORT).show();
            break;
          case AdRequest.ERROR_CODE_INVALID_REQUEST:
            Toast.makeText(PlayListsActivity.this,"onAdFailedToLoad banner ERROR_CODE_INVALID_REQUEST",Toast.LENGTH_SHORT).show();
            break;
          case AdRequest.ERROR_CODE_NETWORK_ERROR:
            Toast.makeText(PlayListsActivity.this,"onAdFailedToLoad banner ERROR_CODE_NETWORK_ERROR",Toast.LENGTH_SHORT).show();
            break;
          case AdRequest.ERROR_CODE_NO_FILL:
            Toast.makeText(PlayListsActivity.this,"onAdFailedToLoad banner ERROR_CODE_NO_FILL",Toast.LENGTH_SHORT).show();
            break;
        }
        Log.i("Ads", "onAdFailedToLoad");
      }
    
      @Override
      public void onAdOpened() {
        // Code to be executed when an ad opens an overlay that
        // covers the screen.
        Log.i("Ads", "onAdOpened");
      }
    
      @Override
      public void onAdLeftApplication() {
        // Code to be executed when the user has left the app.
        Log.i("Ads", "onAdLeftApplication");
      }
    
      @Override
      public void onAdClosed() {
        // Code to be executed when when the user is about to return
        // to the app after tapping on an ad.
        Log.i("Ads", "onAdClosed");
      }
    });
    
    0 讨论(0)
  • 2021-01-25 12:48

    You can use actual ad unit id even for development, but your test devices should be added to the list of TEST DEVICES when you build your ad request.

    If it's a valid ad unit id that you are using, you can be sure that ads will appear when you publish your apps. Also, you can check if you are getting hits for your ad unit in Adsense Dashboard.

    If you want to be dead sure, you can just try to install the apk on another device, test it, and then publish it when you see the ads.

    0 讨论(0)
提交回复
热议问题