android 使用 LocalStorage

來源:互聯網
上載者:User

標籤:

PS:本身是.net 出身 因為項目需要 研究了好幾天安卓  這個方法網上也有 自己也寫出來  有時間自己看看 和 給還沒有解決問題的朋友借鑒下,下面有標個重點 是允許使用localstorage 的關鍵
這個還只能使用localstorage 目前正在研究 怎麼用它來在app 中儲存 等研究出來了 再貼
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//執行個體化WebView對象
    webview = new WebView(this);
//設定WebView屬性,能夠執行Javascript指令碼
    webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);//重點
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
webview.getSettings().setAppCachePath(appCachePath);
webview.getSettings().setAllowFileAccess(true);
webview.getSettings().setAppCacheEnabled(true);
//js彈出
webview.setWebChromeClient(new WebChromeClient());
try {
//設定開啟的頁面地址
webview.loadUrl("http://192.168.16.39:8901/");
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// 重寫此方法表明點擊網頁裡面的連結還是在當前的webview裡跳轉,不跳到瀏覽器那邊
view.loadUrl(url);
return true;
}
});
}
catch(Exception ex)
{
ex.printStackTrace();
}
setContentView(webview); }

android 使用 LocalStorage

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.