cordova webview的使用
来源:互联网 发布:2017年太阳黑子数据 编辑:程序博客网 时间:2024/04/25 20:48
</pre><pre name="code" class="java">
</pre><pre name="code" class="java">
//不得不说,官网的api是个大坑。
</pre><pre name="code" class="java">package com.app.phone;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import org.apache.cordova.Config;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaPlugin;import org.apache.cordova.CordovaWebView;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.util.Log;import android.webkit.WebSettings;public class index extends Activity implements CordovaInterface {CordovaWebView cwv; private final ExecutorService threadPool =Executors.newCachedThreadPool();private CordovaPlugin activityResultCallback =null; protected boolean activityResultKeepRunning; // Keep app running when pause is received. (default = true) // If true, then the JavaScript and native code continue to run in the // background // when another application (activity) is started. protected boolean keepRunning = true; /* Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.index); cwv = (CordovaWebView) findViewById(R.id.tutorialView); cwv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); //设置 缓存模式 //开启 database storage API 功能 cwv.getSettings().setDatabaseEnabled(true); String cacheDirPath = getFilesDir().getAbsolutePath()+"nanguamache"; // String cacheDirPath = getCacheDir().getAbsolutePath()+Constant.APP_DB_DIRNAME; Log.i("xiao", "cacheDirPath="+cacheDirPath); //设置数据库缓存路径 cwv.getSettings().setDatabasePath(cacheDirPath); //设置 Application Caches 缓存目录 cwv.getSettings().setAppCachePath(cacheDirPath); //开启 Application Caches 功能 cwv.getSettings().setAppCacheEnabled(true); Config.init(this.getActivity());
//url cwv.loadUrl("http://write.blog.csdn.net/postedit/46045297"); }public void startActivityForResult(CordovaPlugin command, Intent intent,int requestCode) { this.activityResultCallback = command; this.activityResultKeepRunning = this.keepRunning; // If multitasking turned on, then disable it for activities that return // results if (command != null) { this.keepRunning = false; } // Start activity super.startActivityForResult(intent, requestCode); }@Overridepublic void setActivityResultCallback(CordovaPlugin plugin) { this.activityResultCallback = plugin; }@Overridepublic Activity getActivity() {// TODO Auto-generated method stubreturn this;}@Overridepublic Object onMessage(String id, Object data) {// TODO Auto-generated method stubreturn null;}@Overridepublic ExecutorService getThreadPool() {// TODO Auto-generated method stub return threadPool;}}
0 0
- cordova webview的使用
- 使用cordova的加强webview
- 使用cordova的加强webview
- Cordova使用Webview
- Cordova的WebView兼容问题-X5引擎插件
- 使用Cordova来解决HTML5制作的WebView手机不兼容的问题
- [Phonegap+Sencha Touch] 移动开发70 cordova app中使用增强的webview
- Android与H5互调使用cordova的WebView,插件调用,插件编写
- 移动开发:使用桌面chrome调试安卓设备上的chrome和cordova app(webview)
- Cordova IOS 的使用
- Cordova的使用
- Cordova的简单使用
- cordova 的使用
- Cordova+X5(tencent webview)
- [Phonegap+Sencha Touch] 移动开发17 使用桌面chrome调试安卓设备上的chrome和cordova app(webview)
- [Phonegap+Sencha Touch] 移动开发35 让Cordova app使用Chromium内核的WebView(Crosswalk/XWalk)
- 基于cordova实现的webview实现与h5的交互
- cordova工程webview注入本地js库的方法
- 类handler
- 九度oj 1349 数字在排序数组中出现的次数
- 3d数学基础-向量相关操作-用C++实现
- 为 checkbox 添加事件,使选中和非选中时改变其他几个checkbox的可选状态
- 浅谈root原理以及已知漏洞的分析
- cordova webview的使用
- 管理软件的痛处
- 【c#第五次作业】测试 Html2Article 并添加保存功能
- select/poll/epoll之间的区别总结(个人理解)
- 【Linux操作系统】Red Hat中的文件
- 阿庆SQL智能查询分析器,使用delphi开发的一个数据库查询分析管理工具.分享给大家
- 高可用可伸缩架构实用经验谈
- Android中使用正则表达式
- LeetCode 题解(94): Word Ladder