Mój widok WWW nie wywołuje funkcji javascript, która zwraca ostrzeżenie, jak poniżej. Czy ktoś może zasugerować, jak pozbyć się poniższego ostrzeżenia.Metody WebView nie są wywoływane w Androidzie
07-30 10:15:44.031: W/webview_proxy(3770): java.lang.Throwable: Warning: A WebView method was called on thread 'WebViewCoreThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.
Poniżej jest moja funkcja.
public boolean onLongClick(View v){
System.out.println("dfdsf");
// Tell the javascript to handle this if not in selection mode
//if(!this.isInSelectionMode()){
this.getSettings().setJavaScriptEnabled(true);
this.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
this.getSettings().setPluginsEnabled(true);
this.loadUrl("javascript:android.selection.longTouch();");
mScrolling = true;
//this.setJavaScriptEnabled(true);
//}
// Don't let the webview handle it
return true;
}
Czy to samo dotyczy problemu, gdybym wywołał dowolne metody WebView w AsyncTask, to nie zadziała? –
To jest akceptowana odpowiedź i nie widzę setJavaScriptEnabled() lub innych metod dla instancji WebView. – seema
Domyślam się, że korzystasz z nowszej wersji Androida. Ten post został opublikowany na Androida 2.3.3. Nie jestem pewien. W nowszych wersjach należy użyć następującego kodu: 'wv.getSettings(). SetJavaScriptEnabled (true)'. Mam nadzieję, że to rozwiązuje twój problem – ZeusNet