i want to load url for webview from my json string. but i don't understanding what i need to do for that. i'm trying to load url using getIntent().getExtras().getString("anime_img"); but it's not working. how i can do that? i have json data for the url. here i want to load this image url in webview to open Webview Client.
JSON Data:
image: "https://website.com/library/2019/11/03/1572813810_6.jpg"
my code is:
mainWebView = (WebView)findViewById(R.id.webview);
mainWebView.setWebViewClient(new myWebclient());
mainWebView.loadUrl(getIntent().getExtras().getString("anime_img"));
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setEnableSmoothTransition(true);
// Recieve data
String webview = getIntent().getExtras().getString("anime_img");
TextView tv_name = findViewById(R.id.aa_anime_name);
// setting values to each view
tv_name.setText(webview);
how i can load the webview url from my json data?
What do you send to in anime_img key? Is the " https://website.com/library/2019/11/03/1572813810_6.jpg "data returning?
So why do you show it in webview? You can display it using libraries such as Glide, Picasso in Imageview. Show this libraries. Glide , Picasso
If you say, I'll show it on webview.
// Recieve data
String webviewUrl = getIntent().getExtras().getString("anime_img");
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setEnableSmoothTransition(true);
mainWebView = (WebView)findViewById(R.id.webview);
mainWebView.setWebViewClient(webSettings);
mainWebView.loadUrl(webviewUrl);
You can'll try this.
after adding this code my problems has been solved :)
String webviewUrl = getIntent().getExtras().getString("anime_img");
mainWebView = (WebView)findViewById(R.id.webview);
mainWebView.setWebViewClient(new myWebclient());
mainWebView.loadUrl(webviewUrl);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setEnableSmoothTransition(true);
special thanks to fevziomurtekin
Related
When playing twitter video in android web view it shows the message 'by playing this video you agree to the Twitter use of cookies' and video is not played after that.
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
} else
CookieManager.getInstance().setAcceptCookie(true);
}
webView.getSettings().setJavaScriptEnabled(true);
webView.setBackgroundColor(Color.parseColor("#ffffff"));
webView.loadDataWithBaseURL("file:///android_asset/", htmlTemplate, "text/html", "UTF-8", "");
JavaScript is disabled in a WebView by default.
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
UPDATED:
Use TweetView for Native Videos
Launching native video support for Twitter Kit
Call loadDataWithBaseURL instead of loadData, like this:
loadDataWithBaseURL("https://mywebsite.com", mContent, "text/html", "UTF-8", null);
I try to load the Google Map Url in a WebView with the following code:
String url = "http://maps.google.com";
WebView webview = (WebView) findViewById(R.id.webview);
//webview settings
webview.setPadding(0, 0, 0, 0);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl(url);
and it cannot be loaded (blank).
But the other urls (e.g. http://www.google.com) can be loaded without any problem.
Please help !
Hello community wanted to know how to view a PDF file in android api eight studio try these codes but can not = (someone tell me what's wrong? ..
I get all the WebView blank
thanks
WebView wv = (WebView)findViewById(R.id.webView2);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
wv.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
});
wv.loadUrl("www.ues.mx/Docs/alumnos/movilidad/Ejemplo%20de%20Curr%C3%ADculum%20Vitae.pdf");
wv.getSettings().setUseWideViewPort(true);
another way
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setPluginsEnabled(true);
webview.loadUrl("www.ues.mx/Docs/alumnos/movilidad/Ejemplo%20de%20Curr%C3%ADculum%20Vitae.pdf");
setContentView(webview);
PluginsEnabled replaced
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
not work in any way help!
WebView cannot display PDF documents in Android.
You can handle the pdf to either download it and then open a 3rd party app as shown here.
Or you can also use Google Drive viewer.
String myPdfUrl = "http://example.com/awesome.pdf";
String url = "http://docs.google.com/gview?embedded=true&url=" + myPdfUrl;
Log.i(TAG, "Opening PDF: " + url);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
I have a class to load webpage:
webView = (WebView) findViewById(R.id.login_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://google.com");
I want to load a string from strings.xml instead of http://google.com. How can I do this ?
Just change your current code to this
webView = (WebView) findViewById(R.id.login_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(getResources().getString(R.string.url));
You just need to do that
String url = getResources().getString(R.string.url);
I've been having issues trying to get webview from stop zooming in when a user clicks a input field on webview. How can I keep webview from stop zooming in?
Heres my code:
wv = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = wv.getSettings();
wv.setWebViewClient(new WebViewClient());
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setDisplayZoomControls(false);
wv.getSettings().setBuiltInZoomControls(false);
wv.getSettings().setSupportZoom (true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setDefaultZoom(ZoomDensity.FAR);
String form = "<form action='demo_form.asp'><input type='text' name='email' style='font-size: 200%;width:78%;float:left'><input type='submit' value='Submit' style='float:right;width:20%;font-size: 200%'></form>";
String summary = "<html><body>"+form+"</body></html>";
wv.loadData(summary, "text/html", null);