我正在尝试在我的 Android 应用程序中调试 WebView。我做了一些研究,发现 weinre 非常有用。我使用的是 PhoneGap PhoneGap 调试工具的 weinre。
然而,让我感到困惑的是,它只有在我使用它在本机浏览器中调试时才能正常运行,而不是在我打开我的应用程序时运行。当我打开我的应用程序时,它不会显示 web 视图供我检查。
任何人都知道如何使它与 webview 一起工作?或者我必须在本地安装 Weinre 才能使其正常工作?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)this.findViewById(R.id.button1);
this.webview = (WebView)this.findViewById(R.id.webView1);
webview.setWebChromeClient(new WebChromeClient());
final String htmlPre = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"> <script src='http://172.16.0.135:8080/target/target-script-min.js#anonymous'></script> <script>alert('hello')</script></head><body style='margin:0; pading:0; background-color: black;'>";
final String htmlCode =
" <embed style='width:100%; height:100%' src='http://www.platipus.nl/flvplayer/download/1.0/FLVPlayer.swf?fullscreen=true&video=http://www.platipus.nl/flvplayer/download/pl-600.flv&autoplay=true' " +
" autoplay='true' " +
" quality='high' bgcolor='#000000' " +
" name='VideoPlayer' align='middle'" + // width='640' height='480'
" allowScriptAccess='*' allowFullScreen='true'" +
" type='application/x-shockwave-flash' " +
" pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
"";
final String htmlPost = "</body></html>";
this.webview.getSettings().setJavaScriptEnabled(true);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
webview.loadDataWithBaseURL("null", htmlPre+htmlCode+htmlPost, "text/html", "UTF-8", null);
}
});
Now I'm trying something new like this and it does not work anymore, any suggestion? Thanks :)