¿Qué hace stopLoading () realmente hacer?
Sí, sé que la documentación de stopLoading () dice " Detiene la carga actual. "
Pero cuando trato de usarlo para parar de cargar la página que está progresando actualmente antes de cargar una nueva, no parece comportarse como se desea :
- ¿Cuál es la diferencia entre setWebViewClient y setWebChromeClient?
- Cómo establecer un título diferente para el cuadro de diálogo de alerta cuando se carga la página WebView?
- Android - Utilice OkHttp con Webview
- ShouldOverrideUrlLoading se llama SOLAMENTE para ALGUNAS páginas web
- Webview - cambiar la fuente de la página antes de mostrar el sitio web?
07-24 12:53:30.177: V/WebView.loadUrl: http://www.google.com 07-24 12:53:30.227: V/WebViewClient.onPageStarted: http://www.google.com ===> WebView.stopLoading() called here <==== 07-24 12:53:31.917: V/WebView.loadUrl: http://www.stackoverflow.com 07-24 12:53:32.697: V/WebViewClient.onPageFinished: http://www.google.com 07-24 12:53:32.767: V/WebViewClient.onPageStarted: http://www.stackoverflow.com 07-24 12:53:33.587: V/WebViewClient.onPageFinished: http://www.stackoverflow.com
Como se puede ver en el registro, WebViewClient.onPageFinished()
para el primer loadUrl()
se llama a pesar de que se llamó WebView.stopLoading()
aproximadamente 1 segundo antes .
¿Porqué es eso?
¿Qué hace stopLoading () realmente hacer?
- ShouldOverrideUrlLoading no funciona / captura los clics del enlace mientras la página se está cargando
- Android: cómo interceptar un formulario POST en android WebViewClient en el nivel 4 de API
- Habilitación de protocolos SSL específicos con Android WebViewClient
- Android WebView para Facebook como botón
- El controlador onScaleChanged de WebView se llama varias veces
- ShouldOverrideUrlLoading en WebView para Android no se está ejecutando
- ¿Qué se considera onPageFinished en el WebViewClient para Android?
- Android 4.4 dando ERR_CACHE_MISS error en onReceivedError para WebView volver
You786 tiene razón:
public void stopLoading() { checkThread(); // TODO: should we clear all the messages in the queue before sending // STOP_LOADING? switchOutDrawHistory(); mWebViewCore.sendMessage(EventHub.STOP_LOADING); }
Para eso TODO marcados en los mensajes restantes serían procesados en primer lugar. De modo que resulta en lo que sólo tengo curiosidad: al detener la carga en
WebViewClient.onReceivedError(WebView view, int errorCode, String description, String failingUrl)
El WebView realmente no se detiene, sino que carga su propia página 404 (lo que normalmente haría si no llama a stopLoading ()):
11-07 16:30:01.112: I/MainActivity(19189): Loading: http://92.53.45.42 11-07 16:30:01.253: V/MainActivity.WebViewClient(19189): SHOULD_INTERCEPT_REQUEST: http://92.53.45.42/ 11-07 16:30:01.347: V/MainActivity.WebViewClient(19189): PAGE_STARTED: http://92.53.45.42/ 11-07 16:30:01.347: V/MainActivity.WebChromeClient(19189): ON_PROGRESS_CHANGED: 10 11-07 16:30:01.347: V/MainActivity.WebViewClient(19189): LOAD_RESOURCE: http://92.53.45.42/ 11-07 16:30:25.292: I/GATE(19189): <GATE-M>DEV_ACTION_ERROR</GATE-M> 11-07 16:30:25.300: E/MainActivity.WebViewClient(19189): (CONNECT - Failed to connect to the server) -> http://92.53.45.42/ 11-07 16:30:25.300: W/MainActivity.WebViewClient(19189): loading stopped..: 11-07 16:30:25.300: V/MainActivity.WebViewClient(19189): PAGE_STARTED: http://92.53.45.42/ 11-07 16:30:25.300: I/MainActivity.WebViewClient(19189): PAGE_FINISHED: http://92.53.45.42/ 11-07 16:30:25.339: I/MainActivity.WebChromeClient(19189): ON_RECEIVED_TITLE: Webseite nicht verfügbar 11-07 16:30:25.339: V/MainActivity.WebChromeClient(19189): GET_VISITED_HISTORY 11-07 16:30:25.339: I/GATE(19189): <GATE-M>DEV_ACTION_COMPLETED</GATE-M> 11-07 16:30:25.339: V/MainActivity.WebChromeClient(19189): ON_PROGRESS_CHANGED: 100 11-07 16:30:25.339: I/MainActivity.WebViewClient(19189): PAGE_FINISHED: http://92.53.45.42/