8

私は、Android アプリのネイティブ Web ビューを Crosswalk の実装に置き換えることに取り組んでいます。

アプリのほとんどの機能を動作させることができましたが、サービス内で XWalkView を作成することは、まだ克服しようとしている問題です。Webview の作成は問題ではありませんが、XWalkView ではアクティビティ コンテキストを使用する必要があります。ここに誰かがこの問題に遭遇し、考えられる解決策または回避策を知っている場合は、大いに感謝します. ありがとうございます。他の情報が必要な場合は、お問い合わせください。

4

2 に答える 2

3

GitHubbuteloから:

では、横断歩道とは何ですか? なぜ気にするのでしょうか? ウェブサイトをご覧ください: https://crosswalk-project.org/

CrossWalk は HTML5 ランタイムです。これを使用して、「ネイティブ機能」を備えた HTML5 アプリケーションを作成できます。CrossWalk を使用して、Android (x86 および arm アーキテクチャ) および Tizen 用の HTML5 専用アプリケーションを作成できますが、CrossWalk をアプリケーション内のビューとして使用することもできます。アンドロイドプロジェクト。

これは、Android WebView を XWalkView に置き換えて、次のような追加機能を取得できることを意味します。

-WebGl

-WebRTC

-ウェブオーディオ

http://software.intel.com/en-us/html5/articles/crosswalk-application-runtime

CrossWalk WebView を XWalkView に埋め込み、ハイブリッド アプリケーション (html5 機能を備えた Android ネイティブ) にこれらすべての利点を持たせるにはどうすればよいですか?

まず、ランタイムをダウンロードする必要があります。

https://crosswalk-project.org/#documentation/downloads

Android(ARM) バージョンのいずれかをダウンロードします。

ファイル内には、html5 アプリケーションでの作業を開始するために必要なものがすべて含まれています。

このテストでは、Eclipse 内に xwalk-core-library プロジェクトをインポートする必要があります。

基本的なアクティビティを使用して新しい Android プロジェクトを作成し、それをライブラリにリンクして、次のコードをアクティビティに配置します。

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;
    }
}

これをメインレイアウトに配置します

<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>

最後に、/assets/wwwフォルダー内にhtmlのものを入れて、それだけです

于 2016-01-14T14:27:07.817 に答える