0

I did a web to show different videos in HTML5,and the web works. Now I would like to do a google tv app and show this web and work with it. I try with a webView component but the part with javascript doesnt work and show like a plain text($function...) and the rest appear without any format. This is my Activity:

public class Test extends Activity {

WebView mWebView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.vid);
    mWebView = (WebView) findViewById(R.id.web);
    mWebView.getSettings().setJavaScriptEnabled(true);

    if (savedInstanceState != null) {
        mWebView.restoreState(savedInstanceState);
    } else {
        mWebView.loadUrl("http://192.168.2.103:8080/VirtualSTBJSF/vid.xhtml");
        mWebView.setWebViewClient(new verMiWeb());
    }

}

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mWebView.saveState(outState);
}

@Override
public void onStop() {
    super.onStop();
    mWebView.stopLoading();
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {

        mWebView.goBack();

    }
    return super.onKeyDown(keyCode, event);
}
}

class verMiWeb extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
}

 }

and the layout:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <WebView
            android:id="@+id/web"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            />

    </LinearLayout>

Any idea? Thanks for the answers.

david_11
  • 71
  • 2
  • Can you post some more info. I can see you are mWebView.getSettings().setJavaScriptEnabled(true); which is the right thing to do. I wonder though if you have a hidden JS error. Maybe try a simple js test in the web view first? – Krispy Mar 11 '13 at 16:11
  • Can you post the code you are loading into the webview? – Krispy Mar 13 '13 at 20:23
  • I had same problem but this problem was only on the AVD. On real mobile phone was everything ok ... I recommend test your apllication on real phone. – Lukáš Šálek May 07 '13 at 23:08

0 Answers0