Crosswalk web引擎Android中的使用

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>





  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值