Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TV box WebView

I've got a small application that display stream from server to webView. I've installed it to my phone and it works properly, but when i compile it on tv box my WebView doesn't displayed.I've install android WebView from google play but it doesn't help.

Android TV box x96.

Just in case my code:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        String url = "https://www.google.com.ua";

        WebView webView = (WebView) findViewById(R.id.wevView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl(url);
    }

Xml

<WebView
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:id="@+id/wevView">

like image 309
Nick Kyrpenko Avatar asked Mar 16 '26 23:03

Nick Kyrpenko


1 Answers

Firstly, Make sure you added permission for using Internet in your Manifest.

<uses-permission android:name="android.permission.INTERNET" />

Secondly , Add this code before webView.loadUrl(url); :

webView.setWebViewClient(new WebViewClient());

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!