您的位置:首页 > 移动开发 > Android开发

Crosswalk web引擎Android中的使用

2016-03-28 18:07 92 查看
Crosswalk 入门
http://www.mobibrw.com/p=1934
Crosswalk XWalkCookieManager 介绍
http://code.taobao.org/p/crosswalk_browser/diff/3/trunk/XWalkEmbed/src/com/huosu/qingapp
package com.test;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tool.http.HttpSend;
import com.tool.http.WebUrl;

import org.xwalk.core.XWalkCookieManager;
import org.xwalk.core.XWalkView;

public class WebShowActivity extends Activity {
private String  url;
private XWalkView mXWalkView;

@SuppressLint("JavascriptInterface")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_show1);
url = WebUrl.getUrl() + "platform/" + bundle.getString("url")+"?pageId="+bundle.getString("pageid");
mXWalkView = (XWalkView) findViewById(R.id.webView);

XWalkCookieManager xWalkCookieManager=new XWalkCookieManager();
xWalkCookieManager.setCookie(url, HttpSend.SET_COOKIE);//在此注入cookieId,保持连接

mXWalkView.load(url, null);

RelativeLayout goback = (RelativeLayout) findViewById(R.id.gobackRelativeLayout);
goback.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});

}

@Override
protected void onPause() {
super.onPause();
if (mXWalkView != null) {
mXWalkView.pauseTimers();
mXWalkView.onHide();
}
}

@Override
protected void onResume() {
super.onResume();
if (mXWalkView != null) {
mXWalkView.resumeTimers();
mXWalkView.onShow();
}
}

@Override
protected void onDestroy() {
super.onDestroy();
if (mXWalkView != null) {
mXWalkView.onDestroy();
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode,Intent data) {
if (mXWalkView != null) {
mXWalkView.onActivityResult(requestCode, resultCode, data);
}
}

@Override
protected void onNewIntent(Intent intent) {
if (mXWalkView != null) {
mXWalkView.onNewIntent(intent);
}
}
}


布局界面 activity_web_show1.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.leanweb.WebShowActivity">

<org.xwalk.core.XWalkView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

</org.xwalk.core.XWalkView>

</LinearLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: