delight-im / Android-AdvancedWebView

Enhanced WebView component for Android that works as intended out of the box
MIT License
2.38k stars 576 forks source link

admob #122

Open sashamerkulev opened 7 years ago

sashamerkulev commented 7 years ago

it seems this control breaks requesting/loading admob content.

acousticksan commented 7 years ago

This WebView onPause call pauseTimers(), that set all timers at all webviews at pause. I fix it in my code

@Override
    protected void onDestroy() {
        if (webview != null) {
            webview.resumeTimers();
            webview.destroy();
        }
        super.onDestroy();
    }
ocram commented 7 years ago

@AcoustickSan Thanks a lot! Have you been experiencing this problem as well and found that this is a viable solution? So you've verified that the paused timers were indeed the problem for AdMob (or some other JavaScript)?

@sashamerkulev Please try replacing your Gradle dependency with

compile 'com.github.delight-im:Android-AdvancedWebView:75458201f90237e787db84ac091fca79f84beab5'

to see if that changes anything. With that updated dependency, the JavaScript timers should not be paused anymore on API levels 11+ (Android 3.0+). If that was indeed the cause of the problem, as @AcoustickSan suggested, that should help.

sashamerkulev commented 7 years ago

this code webview.resumeTimers(); helps. thank you.

ocram commented 7 years ago

@sashamerkulev and @AcoustickSan Any chance that one of you could test the alternative Gradle dependency to check if that solves the problem as well? Would be good to have a solution that works for everybody without additional code. Thanks!

mark-dlc commented 6 years ago

Hi! Just came along this thread, and because I had a similar problem myself I just like to add something: [pauseTimers](https://developer.android.com/reference/android/webkit/WebView.html#pauseTimers()) will pause all WebViews throughout the app until resumeTimers has been called.

This means that if you pause your webview (e.g. when switching to another fragment/activity in your app) and then show an interstitial (which relies on WebView) the interstitial won't work properly and sometimes can't even be closed.

There appears to be no instance-specific alternative to resumeTimers.