Vì vậy, crosswalk là gì và tại sao tôi quan tâm? Hãy xem tại website: https://crosswalk-project.org/
crosswalk là một thời gian chạy HTML5, bạn có thể sử dụng nó để tạo ra các ứng dụng HTML5 với 'tính năng bản địa' Bạn có thể sử dụng crosswalk để tạo HTML5 chỉ các ứng dụng dành cho Android (x86 và cánh tay kiến trúc) và Tizen nhưng bạn cũng có thể sử dụng CrossWalk làm Chế độ xem trong dự án android .
Điều này có nghĩa bạn có thể thay thế Android WebView với XWalkView và nhận được một số tính năng bổ sung như:
-WebGl
-WebRTC
-WebAudio
http://software.intel.com/en-us/html5/articles/crosswalk-application-runtime
Làm thế nào để nhúng một WebView CrossWalk, từ bây giờ trên một XWalkView, bên trong một ứng dụng Android để có tất cả các tính năng này trên hy vọng của tôi Brid ứng dụng (Android Native với các tính năng html5)
Trước tiên, bạn phải tải về runtime:
https://crosswalk-project.org/#documentation/downloads
Tải về bất kỳ (ARM) phiên bản Android.
Bên trong tệp là mọi thứ bạn cần để bắt đầu làm việc trong ứng dụng html5.
Đối với thử nghiệm này, chúng tôi sẽ cần phải nhập khẩu các dự án xwalk-core-thư viện bên trong Eclipse của chúng tôi
Tạo một dự án Android mới với một liên kết Hoạt động cơ bản nó với thư viện và đặt mã này trong Hoạt động:
package com.example.xwalkwithlibrary;
import org.xwalk.core.XWalkView;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.LinearLayout;
public class XWalkEmbedLib extends Activity {
private LinearLayout commentsLayout;
private XWalkView xWalkWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_xwalk_embed_lib);
commentsLayout=(LinearLayout)findViewById(R.id.principal);
xWalkWebView = new XWalkView(this, this);
xWalkWebView.load("file:///android_asset/www/index.html", null);
commentsLayout.addView(xWalkWebView);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.xwalk_embed_lib, menu);
return true;
}
}
đặt này trên bố cục chính của bạn
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".XWalkMain" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<LinearLayout
android:id="@+id/principal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginLeft="35dp"
android:layout_marginTop="86dp"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
cuối cùng bên trong thư mục /assets/www
bạn đặt công cụ html của bạn và đó là nó
bạn đang làm việc trên android studio hay nhật thực? và chính xác đâu là vấn đề khi sử dụng XWalkView rất đơn giản và tương tự như WebView, bạn có gặp vấn đề với cấu hình không? nhúng nội dung? đoạn trích html5 cụ thể? –
Tôi có XWalkView hoạt động bình thường trong một Hoạt động. Tuy nhiên, việc sử dụng nó trong Dịch vụ là nơi tôi gặp sự cố vì không có Hoạt động nào để truyền cho hàm tạo. – JGray