hey, an android noob needs help here.
i'm trying to get my webview browser to delete the browser history after the homepage has been loaded (so the next user that comes around this public app doesn't see the previous session)
i've made a webview client and put a
public void onPageFinished(WebView webView, String Url ) {
Browser.clearHistory();
but don't know how to change the String Url to the url of the apps homepage.
I also tried adding a second function to my homebutton onclicklistener, but no luck as well, if someone wants to help i can paste that bit of code as well.
thanks
Here how I did;
#Override
public void onPageFinished(WebView view, String url) {
junc.pg.setVisibility(View.INVISIBLE);
if(url.indexOf("a_string_unique_to_your_homepage")!=-1) {
view.clearHistory();
}
}
Here, you can define a unique string for your url. For example if your homepage url is
www.example.com
you can call it with
www.example.com?12345abc
and search for this unique number 12345abc.
It works, I have tested several times.
Sorry Matt you canĀ“t delete your Browser history programatically in Android.
you will achieve that manually
Browser ..> Settings > Clear History > OK
What about?
Browser.clearHistory(getContentResolver());
Browser.clearSearches(getContentResolver());
Related
Good day!
Guys, I have a problem and want your help.
Through a WebView, how do I get when clicked by the user, do not open the options of standard browsers (eg chrome and internet). I saw an app by clicking the link to the page opens normally however, as if open in a custom browser. I found it very interesting, and I wonder how this mechanics.
If anyone know how to create an app that perform the same procedure I am grateful.
For better doubt the APP is this:
https://play.google.com/store/apps/details?id=com.tachanfil.jornaisdobrasil&hl=pt-BR
You have to set up WebViewClient like
this.mWebView.setWebViewClient(new WebViewClient(){
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
view.loadUrl(url);
return true;
}
});
Then your app will display all links in your WebView instead of opening browser
Perhaps you are missing setting your client as the webview client - Refer to
http://developer.android.com/reference/android/webkit/WebView.html#setWebViewClient%28android.webkit.WebViewClient%29
I'm using Webview in my app , i have a simple website, it has two buttons such as Female and Male , if user click that button i want to show the toast message using android app to users which button they clicked
This is my Webview content
I wanted to know that how to get current activity from the webview and i have another doubt also. how to get the current page url in my android app . for example . if give url like www.stackoverflow.com , the user can browse wherever they want , but at particular time , i need to find out user is in which page.?
Thanks in advance. if this question has any mistakes please let me know
Please have a look at WebViewClient
private String mUrl = "";
...
mWebView.setWebViewClient(new WebViewClient()
{
#Override
public void onPageFinished(WebView view, String url)
{
mUrl = url;
}
});
I am using webview in my app. when the user browses to a https site, how do I get the certificate information for the site/page that just finished loading.
Just like how when you click on the green lock icon on chrome browser and it pops up a dialog with certificate information, how do I get it from webview?
Thank you
Answering my own question, dont know how I missed this!!!!
#Override
public void onPageFinished(WebView view, String url)
{
Log.e(view.getCertificate().toString());
}
When I type the url in the text box and click on the Go button the webview loads the required page but when I click on any link inside the webview the address bar which is the text box is not updated with the exact url? How do I go about doing this?
I am trying all varies ways on google not getting the solution - probably key words are wrong. :( - Help on this would be great.
Thanks!
You need to Override onPageFinished method
#Override
public void onPageFinished(WebView view, String url) {
urlEditText.setText(url, TextView.BufferType.NORMAL);
super.onPageFinished(view, url);
}
Hey everyone! Im pretty new to Android and I have a webView under 2 other widgets on the screen(Or w/e you call it). But when ever I navigate the webView, its changes to full screen and i cant see my other widgets. Ive looked all over Google but couldn't find anything, is there some way I can fix this?
Im using this code to navigate:
webView.loadUrl("http://www.example.com/");
Thank you.
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url){
view.loadUrl(url);
return true;
}
});
when you do webView.loadUrl("www.example.com") or if there is a redirection when a hyperlink is clicked or something similar, the android device browser is started. I believe you are stuck with this. Try pasting the above code before you call the webView.loadUrl("www.example.com")
What we are essentially doing is asking the webview to load the url, instead of opening it in the device browser.