handle multiple webview instance in android - android

I want to load two html pages into two different webviews in android.The first html only going to display. The second html should act as background. The script used in second html page need to run, but it won't display to the user. Let me know this is possible in android..
Thanks

Yes dude it is possible
Add a WebView and set it visibility to View.GONE
Like
WebView webView2=new WebView(this);
webView2.setVisibility(View.GONE);
then
webView2.loadUrl("javascript:MyJSFunction(..)

Related

Adding a view between contents inside a Webview

I am working on a newsreader app in which we have a Webview to display news details. Can I add an Admob layout between the contents inside this webview?
Basically, it should look like this,
-Webview
-Paragaraph1
-Admob layout
-Paragraph2
-Webview
There should be only one webview and the Admob layout should be inside the webview, placed between content.
I tried with splitting the html content and loading them in multiple webviews inside a Recyclerview. But its affecting the performance a lot.
Any help regarding this would be appreciated.
I think it isn't possible and also it isn't a good practice as you are adding your ads on someone else's data.
And if it is your data you can always change the HTML page

Add content in to the Webview?

Is any way to add the Html contents in to the webview through the Main Xml file.
I have a one problem.I'm new in the android field,I load the contents from the assets file and normally the webview contents visible but when i going to swipe the page ,that contents not visible only containing black page ,after swipe next page visible...
so ,anyone give me the tips how to solve this problem.
advance in Thanks...
Check this.....
https://developers.google.com/chrome/mobile/docs/webview/gettingstarted
how to show the html contents to the webview using android
I think this link can help you: Displaying Android asset files in a WebView?
However, you should give us more information. If you want to view an external URL, you will need to add permisions on the Android Manifest. If that is not your case and your content is local, maybe the problem is inside your Webpage.

Android webview sometimes not loading images

I have a simple Activity to show a webview and a back button. Here is the code that I use to load the URL that I want in the webview.
The webpage that I am loading in on a server online, it has a few form elements plus a few links that when clicked I need to keep loading them inside the webview.
Now the problem is very often the page loads without the images, I can see the form elements though or only blank white page. I am testing this on wifi so internet is working fine.
Why is it not loading images and how can I make sure it does? I even tried making all images in the html page have absolute paths, but that did not help.
Later Edit: I found out what was causing this. Maybe others will run into this. I had this in the manifest file android:hardwareAccelerated="true". After removing it the content inside all the webviews is loading smoothly.
Second later edit: It is terrible, I get the initial page load now, but forms are not submitting and after some going back and forward to the webview, new images do not load anymore. Is it a memory problem? How do I make it start fresh every time?
WebView wv = (WebView) findViewById(R.id.webview);
wv.getSettings().setBuiltInZoomControls(false);
wv.getSettings().setJavaScriptEnabled(true);
wv.setWebViewClient(new WebViewClient());
wv.loadUrl(filepath);

Android Webview: HTML Content is Overlapping

Html content is overlapping when large content is loading in the web view. Is there a solution
for this problem?
reportView.setBackgroundColor(0);
reportView.getSettings().setBuiltInZoomControls(true);
reportView.setInitialScale(100);
reportView.getSettings().setUseWideViewPort(true);
reportView.clearView();
Try to use:
webSettings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
in webview settings.
Fixed Html content is overlapping issue, when large content is loading in the web view.
webSettings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
In addition to the above line, trying to reset webview instances every time
.

Android - Creating own buttons in webview, retrieving certain contents from website into webview

I'm currently doing a application (project) on android. I would like to know how to create my own buttons in webview, or creating a tab bar in webview. Also, I would want to retrieve certain contents from a website (or rather, from livejournal, to be specifc), like, I do not want the buttons that are in livejournal itself, I just want certain contents, maybe like some live journal posts. Is there any way I could do this?
Thank you so much in advance!
Instead of putting tabs in the WebView you should put the WebView in Tabs. As for pulling information from LiveJournal there are two possibilites. They either have a public api that you can access to get the data you want and use that to populate your app or they don't. If they don't your only recourse would be to pull in the raw html and try to parse it. At that point you might was well just use the webpage as is.

Categories

Resources