I have a page that got elements that when long clicked makes it draggable. It works on the Chrome app but not on my WebView.
This is my WebSettings.
String UA = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19" +
" (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19";
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
settings.setPluginState(android.webkit.WebSettings.PluginState.ON_DEMAND);
settings.setDatabaseEnabled(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setDomStorageEnabled(false);
settings.setUseWideViewPort(true);
settings.setAllowFileAccess(true);
settings.setAppCacheEnabled(true);
settings.setUserAgentString(UA);
I also already enabled long click on the webview by doing webView.setLongClickable(true);
I can now drag the elements after long clicking. But I can only drag 1. After dragging 1 element, I can't drag anything anymore.
The page the webview loads GSAP TweenMax, Draggable, CSSPlugin if that infos will help.
Related
I'm using a webview to open a website. The problem I'm getting is after user clicks on a button, it always get stuck to the Loading dialog and doesn't show the expected results. But in Google Chrome or custom tabs, it works perfectly fine. I'm not overriding onPageFinished(), onPageStarted() or any other webview method, they are as it is. These are my webview settings:
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setSupportMultipleWindows(true);
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
String newUA= "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0";
webView.getSettings().setUserAgentString(newUA);
webView.clearFormData();
webView.getSettings().setSavePassword(false);
webView.getSettings().setSaveFormData(false);
webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(true);
Just wanted to know what settings could be different in custom tabs and my webview that's causing the issue. And I think it's probably not possible but still asking is there any way to imitate the browser settings of custom tabs for the webview so that I can check if it works that way
i need help, my WebView not show website's video player(black square)
But, it is working on phone browser.
Also, i have tried to use some advanced webview from github, same result(balck square).
This my code
webView = (WebView) findViewById(R.id.webview);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true);
settings.setDatabaseEnabled(true);
settings.setSupportZoom(true);
settings.setDisplayZoomControls(true);
settings.setBuiltInZoomControls(true);
settings.setAppCachePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/cache");
settings.setDatabaseEnabled(true);
settings.setDatabasePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/databases");
webView.getSettings().setUserAgentString("wp-android-native");
//webView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 4.1.1; HTC One X Build/JRO03C) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.58 Mobile Safari/537.31");
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
//webView.setInitialScale(100);
webView.loadUrl("http://onlinemoviesbox.com");
Can you please comment below line and check once , am able to play youtube video properly
// webView.getSettings().setUserAgentString("wp-android-native");
I am trying to show this link in android app in webview but the web loads in android device is different from showing in Google Chrome.
Whatsapp link is here :https://web.whatsapp.com/
I am using this code in android to load the above page but it does not load the same page.
mWebView .loadUrl("https://web.whatsapp.com/");// https://tekdude.blogspot.in/");
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
setContentView(mWebView );
You can Use This Code, It Worked For me!!
Copy this code to inside OnCreate Method!! You can edit code according to your requirement.
webView.loadUrl(YOUR URL HERE);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Win64; x64; rv:46.0) Gecko/20100101 Firefox/68.0");
webView.getSettings().setGeolocationEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setSupportMultipleWindows(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setNeedInitialFocus(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
//webView.getSettings().setBlockNetworkLoads(true);
webView.getSettings().setBlockNetworkImage(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.setInitialScale(100);
You can try with changing user agent of your web view.
Example:
String newUA= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
mWebView.getSettings().setUserAgentString(newUA);
Check this link
Setting WebView to view Desktop Site and Not Mobile Site
Change the user agent of webview
like
String newUA= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
mWebView.getSettings().setUserAgentString(newUA);
Alternatively you can also change the settings without changing user agent
webView = (WebView)findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
I have a phone, Galaxy S4 and a tablet, Galaxy Tab both running Android 4.4.2.
I'm running a custom app that loads a Chrome Web View:
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebContentsDebuggingEnabled(true);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
mWebView.addJavascriptInterface(this, "Android");
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setAcceptThirdPartyCookies(mWebView,true);
} else {
cookieManager.setAcceptCookie(true);
}
This works absolutely fine on the phone, however on the tablet, certain css rules are not being applied:
transform: rotate(180deg);
I do not have the -webkit prefix, but since it works on the phone, it leads me to believe that it is using the default webview and not the Chrome one
http://caniuse.com/#feat=transforms2d
Also, I can attach the chrome desktop browser inspect tool while debugging to the phone, but not to the table.
Is there any reason why a Chrome Web View would not load on this device?
I'm trying to load maps.google.com when user click a button with this url
http://maps.google.com/maps?saddr=40.702297,-73.796015&daddr=40.73682,-73.989937&mrsp=0,1
It works as I expected, but when I click
It load only partial of screen(not cover all my screen).
NOTE: I tried to load the same url in browser of emulator, everything is working fine.
Here is setting for the webview that I used to load a web:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.webview_layout);
this.webview = (WebView)findViewById(R.id.myWebview);
WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
//....follow by normal setup of webview.setWebViewClient
}
I found a solution for this problem. In my webview I used a line of code in order to load Twitter website (without this line it will only load a white screen)
webSettings.setUserAgentString("Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3");