If your webview doesn't load an external page (from the internet) you don't need any permission, otherwise you only need the internet permission:
<uses-permission android:name="android.permission.INTERNET" />
That image means you probably have an HTML <video>
tag on your HTML page, which is taking the whole screen (height - width), and which is declared as an auto-playing video, by default Android blocks Auto-playing videos.
Example:
<video controls autoplay>
<source src="movie.mp4" type="video/mp4">
</video>
So,
1- Make sure you use the WebChromeClient
2- Here's a method to initialize your webview:
@SuppressLint ("SetJavaScriptEnabled")
private void initWebview () {
webview = findViewById (R.id.my_webview);
webView.setWebChromeClient (new WebChromeClient () {
@Override
public boolean onConsoleMessage (ConsoleMessage consoleMessage) {
Log.e ("WebView - Logger", consoleMessage.messageLevel () + " : " + consoleMessage.lineNumber () + " : " + consoleMessage.message ());
return true;
}
});
WebSettings webSettings = webView.getSettings ();
webSettings.setJavaScriptEnabled (true);
webSettings.setUseWideViewPort (true);
webSettings.setLoadWithOverviewMode (true);
webSettings.setCacheMode (WebSettings.LOAD_NO_CACHE);
}
3-
If you wanna allow whatever HTML video in your pages to be played automatically (like probably in your case), without showing that big "Play" image add to your initWebview
method: webSettings.setMediaPlaybackRequiresUserGesture (false);
If you don't want to allow the autoplaying remove the autoplay
attribute from the <video>
tag in your HTML page.