X5最小缓存设置
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
import "android.support.*"
import "com.tencent.smtt.sdk.*"
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setDisplayZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setDomStorageEnabled(false);
webView.getSettings().setDatabaseEnabled(false);
webView.getSettings().setAppCacheEnabled(false);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setSaveFormData(false);
webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setBlockNetworkImage(false);
webView.getSettings().setAllowFileAccessFromFileURLs(false);
webView.getSettings().setAllowUniversalAccessFromFileURLs(false);
webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportMultipleWindows(true);
webView.getSettings().setGeolocationEnabled(true);
webView.getSettings().setDefaultTextEncodingName("UTF-8");
webView.getSettings().setAppCacheMaxSize(Long.MAX_VALUE);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
X5清理缓存
--程序启动时会执行的事件
local hh={};webView.addJavascriptInterface(hh,'JsInterface');
webView.addJavascriptInterface({},'JsInterface')
appinfo=this.getPackageManager().getApplicationInfo(this.getPackageName(),0)
applabel=this.getPackageManager().getApplicationLabel(appinfo)
function onKeyDown(key,event)
if(key==4)then
webView.clearCache(true)
if(webView.canGoBack())then
webView.goBack()
else
退出确认=对话框()
.设置标题("提示")
.设置消息("您确定要退出 "..applabel.." 吗?")
退出按钮={
[1]=function()
退出确认
.设置积极按钮("确定",function()
webView.clearCache(true)
执行Shell("rm -rf /sdcard/"..this.packageName)
执行Shell("rm -rf /storage/emulated/0/"..this.packageName)
执行Shell("rm -rf /sdcard/Android/data/"..this.packageName)
执行Shell("rm -rf /storage/emulated/0/Android/data/"..this.packageName)
执行Shell("rm -rf /data/data/"..this.packageName.."/cache")
执行Shell("rm -rf /data/data/"..this.packageName.."/code_cache")
执行Shell("rm -rf /data/data/"..this.packageName.."/app_webview")
执行Shell("rm -rf /data/data/"..this.packageName.."/app_textures")
执行Shell("rm -rf /data/data/"..this.packageName.."/files/data")
执行Shell("rm -rf /data/data/"..this.packageName.."/files/live_log")
退出程序()
end)
.设置中立按钮("清空数据",function()
对话框()
.设置标题("提示")
.设置消息("清空应用数据后再次运行程序将变得缓慢\n您确定要清空 "..applabel.." 的全部数据吗?")
.设置积极按钮("确定",function()
执行Shell("rm -rf /sdcard/"..this.packageName)
执行Shell("rm -rf /storage/emulated/0/"..this.packageName)
执行Shell("rm -rf /sdcard/Android/data/"..this.packageName)
执行Shell("rm -rf /storage/emulated/0/Android/data/"..this.packageName)
os.execute("pm clear "..this.packageName)
end)
.设置消极按钮("取消")
.显示()
end)
.设置消极按钮("取消")
end}
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1, 6)))
退出按钮[math.random(1,1)]()
退出确认.show()
end
return true
end
end
网友评论