开发者

android: delete history after homepage load

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 sessio开发者_运维技巧n)

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());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜