I have taken a web page which has several videos that show in modals and put it in a WebView. When I open this page on my laptop I get full volume. When I launch the app and try to view the video I don't see video controls and the sound on the tablet is turned all the way up, yet it is very quiet. What am I missing here?
The WebView
public class MainActivity extends AppCompatActivity {
private WebView webView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView=findViewById(R.id.webviewid);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("file:///android_asset/index.html");
}
}
Turn JavaScript On for the WebView.
mWebView.getSettings().setJavaScriptEnabled(true);
Related
I am trying to load http://www.bing.com or https://www.bing.com in web view but it is not loading. When I debug I found that the onPageFinished() callback is executed and the web view is still blank.
I have tried with other websites such as http://www.google.com it works fine.
Here is my code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
WebView webView = findViewById(R.id.web_view);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewController());
webView.loadUrl("http://www.bing.com");
}
public class WebViewController extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
In the logs I'm getting the following message when I'm trying to load bing website
2020-04-10 17:41:31.981 6044-6044/com.mawinbet.android I/chromium: [INFO:CONSOLE(0)] "The resource http://www.bing.com/rb/2U/cj,nj/6BsKE-ZQeKe0vHb0vclH0k01aag.js?bu=BUBKDlVY was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.", source: (0)
Can you please tell me how to solve this problem.
I made a url to open through webview and everything worked fine for me except some buttons of the webpage it doesn't respond anything
public class browse extends AppCompatActivity {
WebView appwebview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse);
String profileID= getIntent().getStringExtra("inputtext");
Toast.makeText(getApplicationContext(),profileID,Toast.LENGTH_SHORT).show();
appwebview=(WebView) findViewById(R.id.webview);
WebSettings webSettings= appwebview.getSettings();
webSettings.getJavaScriptEnabled();
appwebview.loadUrl("https://statsroyale.com/profile/"+profileID);
appwebview.setWebViewClient(new WebViewClient());
}
#Override
public void onBackPressed() {
if(appwebview.canGoBack())
appwebview.goBack();
else
super.onBackPressed();
}
}
the intent passes text of textfield from MainActivity and depending on that text i used to show profile.
Probably you forgot to activate Javascript in the WebView.
Please try this:
webSettings.setJavaScriptEnabled(true);
instead of:
webSettings.getJavaScriptEnabled();
A couple of other settings could help:
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setAllowFileAccess(true);
settings.setAllowContentAccess(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setDomStorageEnabled(true);
Add this code to appwebview when it finishes loading as sometimes javascript interaction does not work properly.
appwebview.requestFocus();
I am working on my first android project which is based on Google Forms.
I've done pretty much everything except my main part which is showing forms in webview. The form is getting display but the Sign In button is not clickable.
public class cadexpo extends AppCompatActivity {
private static WebView browser;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cadexpo);
browser = (WebView) findViewById(R.id.webView);
browser.getSettings().getJavaScriptEnabled();
WebSettings browser = browser.getSettings();
browser.loadUrl("https://drive.google.com/open?id=1VLKIncq9bTJnWqxbOHc3foTeSLykP7AQyL0Si1cIQ1I");
Please help me in fixing it.
Enable javascript for webview
WebSettings webSettings = browser.getSettings();
webSettings.setJavaScriptEnabled(true);
I am new to Android development and I am trying to make an app for my video website which has videos from YouTube.
The problem I am having right now is that the embedded iframe videos don't show the fullscreen button. I have been searching for a solution but have yet to find one that works for me.
mainActivity.java:
public class MainActivity extends Activity {
private WebView wv1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webView);
WebView myWebView = (WebView) findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
wv1=(WebView)findViewById(R.id.webView);
wv1.setWebChromeClient(new WebChromeClient() {
});
wv1.setWebViewClient(new MyBrowser());
wv1.loadUrl("http://m.youtube.com");
} .....
Thanks for any help.
I'm trying to make an app with a webview of facebook.com, i want to load custom css but i don't know how. I searched on Google but found old tutorials and i read that it has changed in Android Studio 2.0
Here is my code:
private WebView myWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView)findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("https://www.facebook.com/");
myWebView.setWebViewClient(new WebViewClient());
}