android - 不记录广告曝光。没有活跃的 Activity 。 'Google Admob RewardedVideo'

标签 android firebase android-activity google-admob

当我想切换到另一个 Activity 时出现错误。问题现在就开始了:我试图添加“Google Admob RewardedVideo”。添加标志广告后没有问题。

23198-23236/com.metabrain.emre V/FA: Recording user engagement, ms: 46984

23198-23236/com.metabrain.emre V/FA: Activity paused, time: 84767609

23198-23236/com.metabrain.emre V/FA: Not logging ad unit exposure. No active activity

23198-23236/com.metabrain.emre V/FA: Not logging ad exposure. No active activity



信息:

21105-21105/? W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection

18621-18621/? I/FA: App measurement is starting up, version: 10084

18621-18621/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE

18621-18621/? I/FA: To enable faster debug mode event logging run: adb shell setprop debug.firebase.analytics.app com.ext.ui

18276-18484/? I/FA-SVC: App measurement is starting up, version: 11302

18276-18674/? I/FA-SVC: This instance being marked as an uploader

19034-19034/com.metabrain.emre I/FA: App measurement is starting up, version: 11020

19034-19034/com.metabrain.emre I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE

19034-19034/com.metabrain.emre I/FA: To enable faster debug mode event logging run: adb shell setprop debug.firebase.analytics.app com.metabrain.emre

19034-19069/com.metabrain.emre I/FA: Tag Manager is not found and thus will not be used



详细:

08-13 15:05:14.959 19034-19069/com.metabrain.emre I/FA: Tag Manager is not found and thus will not be used 08-13 15:05:14.992 19034-19069/com.metabrain.emre D/FA: Logging event (FE): ad_query(_aq), Bundle[{firebase_event_origin(_o)=am, ad_event_id(_aeid)=-949480578009143333}] 08-13 15:05:15.041 19034-19069/com.metabrain.emre V/FA: Using measurement service 08-13 15:05:15.041 19034-19069/com.metabrain.emre V/FA: Connection attempt already in progress 08-13 15:05:15.043 19034-19069/com.metabrain.emre D/FA: Logging event (FE): ad_query(_aq), Bundle[{firebase_event_origin(_o)=am, ad_event_id(_aeid)=-949480578009143354}] 08-13 15:05:15.057 19034-19069/com.metabrain.emre V/FA: Using measurement service 08-13 15:05:15.057 19034-19069/com.metabrain.emre V/FA: Connection attempt already in progress 08-13 15:05:15.085 19034-19069/com.metabrain.emre V/FA: Using measurement service 08-13 15:05:15.085 19034-19069/com.metabrain.emre V/FA: Connection attempt already in progress 08-13 15:05:15.087 19034-19069/com.metabrain.emre D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=Main_Activity, firebase_screen_id(_si)=-949480578009143353}] 08-13 15:05:15.101 19034-19069/com.metabrain.emre V/FA: Using measurement service 08-13 15:05:15.101 19034-19069/com.metabrain.emre V/FA: Connection attempt already in progress 08-13 15:05:15.105 19034-19069/com.metabrain.emre V/FA: Activity resumed, time: 83370181 08-13 15:05:15.270 19034-19069/com.metabrain.emre V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 184 08-13 15:05:15.270 19034-19069/com.metabrain.emre V/FA: Using measurement service 08-13 15:05:15.270 19034-19069/com.metabrain.emre V/FA: Connection attempt already in progress 08-13 15:05:15.272 19034-19069/com.metabrain.emre V/FA: Activity paused, time: 83370365 08-13 15:05:15.306 19034-19069/com.metabrain.emre D/FA: Logging event (FE): app_exception(_ae), Bundle[{firebase_event_origin(_o)=crash, timestamp=1502625915299, fatal=1}] 08-13 15:05:15.324 19034-19069/com.metabrain.emre V/FA: Using measurement service 08-13 15:05:15.324 19034-19069/com.metabrain.emre V/FA: Connection attempt already in progress



依赖项:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        compile 'com.google.firebase:firebase-core:11.0.4'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.google.firebase:firebase-ads:11.0.4'
    compile 'com.google.firebase:firebase-crash:11.0.4'
    ...
    testCompile 'junit:junit:4.12'
    compile "com.google.android.gms:play-services-games:11.0.4"
    compile 'com.android.support:multidex:1.0.1'
    compile project(path: ':BaseGameUtils')
}

最佳答案

我在插页式广告中遇到过这样的问题,发现用户正试图离开 Activity ,而插页式广告已经加载但尚未向用户显示。我已经通过以下方式解决了这个问题:

  • 定义一个 bool 标志:
    private boolean addIsReady;
  • Set the flag status inside the adListener class when you load your ad:

    myAd.setAdListener(new AdListener() {
             @Override
             public void onAdLoaded() {
                 addIsReady = true;
             }
    
             @Override
             public void onAdFailedToLoad(int errorCode) {
                 addIsReady = false;
             }
     }
  • 在向用户展示您的广告之前,将标志设置为 false,方法如下:
    void showInterstitialAd(){
      if (mmAd == null) return;
         if (myAd.isLoaded()) {
             addIsReady = false;
             myAd.show();
         }
     }
  • check if the is already loaded before the user leaves the activity and if it's true show the already loaded ad to the user (this step solved the issue in my case)

    @Override
    public void onBackPressed() {
        if (addIsReady){
            requiredLawIndex = -1;
            showInterstitialAd();
        }
        super.onBackPressed();
    }
    

  • 我希望这个答案可以帮助你。

    关于android - 不记录广告曝光。没有活跃的 Activity 。 'Google Admob RewardedVideo',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45660436/

    相关文章:

    Android:为什么 SQLite 表中的文本字段需要 getBlob() 函数?

    Firebase身份验证持续时间过长

    android - 从应用程序 Android 注销

    android - 在Android中,一个activity可以有多少个线程?

    java - 处理 "Activity has been destroyed"(java.lang.IllegalStateException) 异常?

    Android如何发出http请求以获取ImageView的图像链接

    java - 在android中使用服务下载多个文件

    安卓语音识别指令

    firebase - 云 Firestore : Filter based on object content (via Flutter)

    firebase - VueJS + Firebase Auth + Route Guards - 同步问题/竞争条件