I want to be able to retrieve the domain name in a webview in which the user is able to enter in the URL. I want to post the domain name instead of the URL if this is possible. Any help is greatly appreciated.
You could call getTitle() and getUrl() on the WebView to get the current title and URL, if that's what you're looking for.
You can create a WebViewClient for the WebView and override its onLoadResource method. This will tell you whenever a new web page is being loaded in the WebView, so you can parse that to get the domain and do whatever you need to do with it.
Related
I am making an app for tracking courier. the user will enter tracking no.in apps textview and click submit this will open couriers website tracking page i.e fedex in a webview inside the App.
Now i want a way to pass those tracking no from my app to webview's website input field and click the submit button on the website automatically
I don't think this the way you should do that, you should look for a url that takes the tracking location number as a query and return the proper page
something like that http://example.com/over/there?number=441222
Update
I've looked at the page you've mentioned in the comments and all I can get is that it submits a post request as a form input
POST url: https://www.myutiitsl.com/PAN_ONLINE/PANTrackerSearch.action
parameter names are
appNo
panNo
I wish I had more knowledge as a web developer but this the way that could work with you try to make sure the post url is correct and the parameters I mentioned also correct and it should work with you
I am stuck at an issue, I don't know if its possible or not.
I need to call a HTML page, but the page has some content being loaded via Javascript too and I need to get that also.
Is this some how possible ?
Currently I have used plain: new URL(url).openConnection() and it's not returning that.
Any Help ?
Thanks
To do that you'll need to host a WebView in your application. It can be hidden if you want. Call the webview loadUrl to load the content you want. Handle the WebViewClient onPageFinished so you know all of the content has loaded, and then use the javascript bridge interface (addJavascriptInterface) to pass the HTML back up to the application.
Is there a way to hide part of the url of a certain page?
For example instead of www.mypage.com/login&userid=0011/
to show only www.mypage.com/login ?
I am developing my webpage with Liferay and I am using jsp to show the content of the page and Java to complete the actions I want to be done.
Any help will be appreciated!
Thanks in advance!
The userid here is the 'request parameter'.
To hide request parameters use Post instead of Get.
The GET method is the default method to pass information from browser to web server and it produces a long string that appears in your browser's address bar.
Never use the GET method if you have password or other sensitive information to pass to the server.
e.g.
<form action="myForm.jsp" method="GET">
A generally more reliable method of passing information is the POST method.This method packages the information in exactly the same way as GET methods, but instead of sending it as a text string after a ? in the URL it sends it as a separate message.
e.g.
<form action="myForm.jsp" method="POST">
You can use String#substring(int beginIndex,int endIndex) method of String to take substring from the given string.
Try something like this:
String str = "www.mypage.com/login&userid=0011/";
String needed = str.substring(0,str.indexOf("&"));
In Apache you can create .htaccess-Files to accomplish that. I dont know, what it in jsp is, but i think you can easyly google it now.
i have an application that fetch html from a websites, exactly in a webpage permitted only tu logged in user, so i have setted the login cookie and i get back the html webpage to a string, i tryied to easily take this string off from emulator, but i can't do copy-paste trought emulator-pc, does someone know how can i load a webview to reder my string and make me seeing if i am logged in and all work or not?
If it's possible i'd like to directly render the string, without saving it to an html file and opening it... is this possible?
Thanks, matteo.
Setting webview content form String:
public static void loadHtmlToWebView(WebView view, String html) {
view.loadData(Base64.encodeToString(html.getBytes(), Base64.DEFAULT) , "text/html", "base64");
}
I have a website loaded in WebView on Android 1.6 and I want to get the HTML-Code of a Site which was generated when the user hits Submit. The parameter get submitted by GET, if that's important.
Then I want to change the HTML-Code and show it to the user, without showing the real Answer-page first.
Maybe I could use onFormResubmission() from WebViewClient? But I really have no idea how.
Thanks for the help!
This is not possible with WebView's API, because you cannot "get the HTML-Code of a Site" that was retrieved by WebView. You are welcome to perform your own HTTP operations using HttpClient and feed the results to WebView via loadData() or loadDataWithBaseURL().