Splash screen while loading a url in a webview in android app

I do it by initially showing an ImageView and then once the WebView has loaded, swapping their visibility like this WebView wv = (WebView) findViewById(R.id.webView1); wv.getSettings().setJavaScriptEnabled(true); wv.setWebViewClient(new WebViewClient() { … @Override public void onPageFinished(WebView view, String url) { //hide loading image findViewById(R.id.imageLoading1).setVisibility(View.GONE); //show webview findViewById(R.id.webView1).setVisibility(View.VISIBLE); } }); wv.loadUrl(“http://yoururlhere.com”); And my xml layout looks like this … Read more

Android WebView UTF-8 not showing

Use: mWebView.loadDataWithBaseURL(null, “將賦予他們的傳教工作標示為”, “text/html”, “utf-8”, null); or using WebSettings with setDefaultTextEncoding: WebSettings settings = mWebView.getSettings(); settings.setDefaultTextEncodingName(“utf-8″); For recent versions of Android, API 16 to 22 it was tested and work properly using loadData() method, requires the mimeType to include: “charset=utf-8”. WebView mWebView = (WebView) findViewById(R.id.myWebView); WebSettings settings = mWebView.getSettings(); settings.setDefaultTextEncodingName(“utf-8”); mWebView.loadData(myCharacters, “text/html; charset=utf-8”,null); or mWebView.loadData(myCharacters, … Read more

Android WebView always returns null for javascript getElementById on loadUrl

Finally I found a solution! And it is a really strange behaviour. First of all you need to specify setDomStorageEnabled(true) on your webview. Otherwise the DOM doesn’t work. I wonder why no tutorial gave a hint about. But ok. myview.getSettings().setDomStorageEnabled(true); After this I ended up in a white blank page with only the value I … Read more

phonegap: cookie based authentication (PHP) not working [webview]

i figured it out: you have to change the phonegap_delegate.m file and add the following to the init method: – (id) init { /** If you need to do any extra app-specific initialization, you can do it here * -jm **/ //special setting to accept cookies via ajax-request NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; … Read more

Enable longClick in WebView

I had this same problem. Unfortunately, I could not find a way to make the standard browser menu options appear. You have to implement each one yourself. What I did was to register the WebView for context menus with activity.registerForContextMenu(webView). Then I subclassed the WebView and overrode this method: @Override protected void onCreateContextMenu(ContextMenu menu) { … Read more

Youtube Video in WebView doesn’t load

Now it works, with a combination of some things: public class Videos extends Activity { private WebView mWebView; private String extra; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.videos_layout); extra = getIntent().getStringExtra(“VideosId”); mWebView = (WebView) findViewById(R.id.videos_webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setPluginsEnabled(true); final Activity activity = this; mWebView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { // Activities … Read more

Create a PDF from Webview on Android

WebView has built-in functionality to generate PDFs which is made available by using PrintManager Service. For your use case, I would suggest you to write/store the final output of WebView’s PrintAdapter which is a PDF file to a local file and go from there. This link will walk you through the details and implementation. http://www.annalytics.co.uk/android/pdf/2017/04/06/Save-PDF-From-An-Android-WebView/ … Read more

Is there any way to have WebView auto-link URLs and phone numbers in Android?

If you are loading your own (web) content from a String, then you can do something like this: final String content = “My email is: [email protected] …”; Spannable sp = new SpannableString(content); Linkify.addLinks(sp, Linkify.ALL); final String html = “<body>” + Html.toHtml(sp) + “</body>”; myWebView.loadData(html, “text/html”, “utf-8”);

JavaFX resource handling: Load HTML files in WebView

You get this exception because your url variable is null on this line: String url = WebViewSample.class.getResource(“/map.html”).toExternalForm(); You have several options with getResource(): If the resource is the same directory as the class, then you can use String url = WebViewSample.class.getResource(“map.html”).toExternalForm(); Using beginning slash(“https://stackoverflow.com/”) means relative path to the project root.: In your particular case, … Read more