How to prevent a scrollview from scrolling to a webview after data is loaded?

I had the same problem, after hours of trying several ideas, what finally worked for me was simply adding the descendantFocusability attribute to the ScrollView’s containing LinearLayout, with the value blocksDescendants. In your case: <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” android:descendantFocusability=”blocksDescendants” > Haven’t had the problem reoccur since.

WebView link click open default browser

I had to do the same thing today and I have found a very useful answer on StackOverflow that I want to share here in case someone else needs it. Source (from sven) webView.setWebViewClient(new WebViewClient(){ public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url != null && (url.startsWith(“http://”) || url.startsWith(“https://”))) { view.getContext().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(url))); … Read more

How to load external webpage in WebView

Thanks to this post, I finally found the solution. Here is the code: import android.app.Activity; import android.os.Bundle; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; import android.annotation.TargetApi; public class Main extends Activity { private WebView mWebview ; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mWebview = new WebView(this); mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript final … Read more

Android WebView, how to handle redirects in app instead of opening a browser

Create a WebViewClient, and override the shouldOverrideUrlLoading method. webview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url){ // do your handling codes here, which url is the requested url // probably you need to open that url rather than redirect: view.loadUrl(url); return false; // then it is not handled by default action } });

Is `shouldOverrideUrlLoading` really deprecated? What can I use instead?

Documenting in detail for future readers: The short answer is you need to override both the methods. The shouldOverrideUrlLoading(WebView view, String url) method is deprecated in API 24 and the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method is added in API 24. If you are targeting older versions of android, you need the former method, and if … Read more

WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS [duplicate]

Solution: Add the below line in your application tag: android:usesCleartextTraffic=”true” As shown below: <application …. android:usesCleartextTraffic=”true” ….> UPDATE: If you have network security config such as: android:networkSecurityConfig=”@xml/network_security_config” No Need to set clear text traffic to true as shown above, instead use the below code: <?xml version=”1.0″ encoding=”utf-8″?> <network-security-config> <domain-config cleartextTrafficPermitted=”true”> …. …. </domain-config> <base-config cleartextTrafficPermitted=”false”/> … Read more

Load HTML file into WebView

The easiest way would probably be to put your web resources into the assets folder then call: webView.loadUrl(“file:///android_asset/filename.html”); For Complete Communication between Java and Webview See This Update: The assets folder is usually the following folder: <project>/src/main/assets This can be changed in the asset folder configuration setting in your <app>.iml file as: <option name=”ASSETS_FOLDER_RELATIVE_PATH” value=”/src/main/assets” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)