phonegap 新窗口 WebView

自定义WebView窗口打开

import com.ap.work.QuickWeb

public class QuickPlugin extends CordovaPlugin {


/**
	 * 新开WebView 打开链接
	 * 
	 * @param context
	 * @return
	 */
	public void WebUrl(JSONArray data, CallbackContext callbackContext) {
		try {
			// 下面两句最关键,利用intent启动新的Activity
			Intent intent = new Intent().setClass(cordova.getActivity(),QuickWeb.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
					| Intent.FLAG_ACTIVITY_CLEAR_TOP);

			intent.putExtra("url", data.getString(0));

			this.cordova.startActivityForResult(this, intent, 1);
			
			// 下面三句为cordova插件回调页面的逻辑代码
			PluginResult mPlugin = new PluginResult(PluginResult.Status.NO_RESULT);

			mPlugin.setKeepCallback(true);
			callbackContext.sendPluginResult(mPlugin);
			callbackContext.success("success");

		} catch (Exception e) {
			QuickBLL.Log_saveFile("Err:WebUrl|" + e.getMessage());
			//e.printStackTrace();
			callbackContext.error("执行错误");
		}
		
	}


}

 

posted @ 2015-05-10 18:38  AppleCn  阅读(378)  评论(0编辑  收藏  举报