During my activity 开发者_运维技巧I'm sending an intent to the browser in order to display a webpage :
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://ww.mywebpage.com");
startActivity(i);
I need to make sure that before sending the intent the browser cache and history are cleared so that the page get loaded from server directly and not from phone.
So far I've found the 2 following but I'm not sure they are used correctly :
Browser.clearHistory(getContentResolver());
Browser.clearSearches(getContentResolver());
Also with that cache is not cleared.
Do you know how to do that ?
First, you are assuming there is only one Web browser for Android. You are mistaken, and will be increasingly mistaken over time. Steel, Dolphin, Opera, etc. are already in production for Android, and Mozilla's Fennec is coming along nicely. This solution will not help you with other browsers.
Second, if a browser is incorrectly caching your data, your problem is probably on the server (i.e., not sending proper cache control headers). I'd try to fix it there, so that it will behave properly across all browsers.
Third, wiping the user's entire history and searches, to satisfy your requirements, is rather unprofessional. How would you like some desktop app wiping out your desktop browser's history and searches?
Fourth, you cannot clear the browser's cache programmatically.
Yes... and if you must assert more control on the client side rather than fixing it at the server, you'll need to display the content with a webview inside your application where you have full control, rather than delegating to the browser (which is a separate application running under a separate user id and separate security context that you can't mess with).
精彩评论