Victor2018 / DocViewer

android DocViewer support view word excel ppt pdf txt image in sdcard & uri & assets & url
32 stars 8 forks source link

Error of not displaying Admob when the file open. #13

Closed duongpt582 closed 1 month ago

duongpt582 commented 1 month ago

When document files such as word, ppt, excel cannot be read, my intersitial ad freezes and cannot be turned off or I cannot create new ads (ad error code is 0). I am using jetpack compose this my code to open your lib:

AndroidView(
                        factory = { context ->
                                DocView(context).apply {
                                    configurationDocView.value = this

                                    (configurationDocView.value as DocView).openDoc(
                                        activity = activity,
                                        docUrl = state.docEntity?.filePath,
                                        docSourceType = DocSourceType.PATH,
                                        fileType = if (state.fileType == FileType.TXT) {
                                            -1
                                        } else {
                                            state.fileType ?: 1
                                        },
                                        engine = DocEngine.INTERNAL
                                    )
                                }
                        },

                modifier = Modifier.fillMaxSize(),
                )
duongpt582 commented 1 month ago

Error by Webview: I was able to solve it by removing all references to pauseTimers()

class DocWebView
    fun onDestroy() {
        try {
            mDocView.clearHistory();
            mDocView.clearCache(true)
            mDocView.loadUrl("about:blank")
            mDocView.freeMemory()
//            mDocView.pauseTimers()
            mDocView.destroy() // Note that mWebView.destroy() and mWebView = null do the exact same thing
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }