MainActivity.java
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() != KeyEvent.ACTION_UP) { //按下有用,key up 無用
if (mXWalkView != null && mXWalkView.getNavigationHistory().canGoBack()) {
mXWalkView.getNavigationHistory().navigate(XWalkNavigationHistory.Direction.BACKWARD, 1);
return true;
}
}
return false;
}
http://www.cnblogs.com/ct2011/p/4100132.html
1、build.gradle
repositories {
maven {
url ‘https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
}
}
compile ‘org.xwalk:xwalk_core_library:18.48.477.13’
2、active_main.xml
<org.xwalk.core.XWalkView android:id="@+id/activity_main"
xmlns:android=“http://schemas.android.com/apk/res/android"
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”>
</org.xwalk.core.XWalkView>
3、MainActivity.java
mXWalkView = (XWalkView) findViewById(R.id.activity_main);
mXWalkView.load(“https://blueimp.github.io/jQuery-File-Upload/", null);
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mXWalkView.onActivityResult(requestCode, resultCode, data);
} 4、AndroidManifest.xml
android:hardwareAccelerated=“true”
剛用intel XDK 做crosswalk,用codova,做純網頁 app,非常慢…..慢到極點了
crosswalk是把最新的chorme的核心,包在apk中,只有4.4才是內建chorme新的核心,所以crosswalk就是把apk包了chorme,讓apk走html5架構暴快
如果單純crosswalk比cocoonjs還快,目前看有人測試,所以是慢在codova…..
codova太慢了,如果用android studio 做原生的webview,連網頁超快,但我現在手機,雖然是4.2,但底層已換chorme,所以我測很快,所以現在兩種情況:
一、以後走4.4後,chorme為底層broswer時,html5暴快,
二、等android studio可以包crosswalk時,就算4.x的都暴快,4.0以下不能用crosswalk,但包了crosswalk會胖20 MB
但,很妙的是,如果走codova crosswalk XDK,放到手機中,吃的記憶體不多,5x~8x MB,但會自動掛掉 …….
Now HAHA!!
https://diego.org/2015/01/07/embedding-crosswalk-in-android-studio/ https://crosswalk-project.org/documentation/embedding_crosswalk/crosswalk_aar.html https://www.timroes.de/2013/11/23/old-webview-vs-chromium-webview/
Have you looked at crosswalk? https://crosswalk-project.org/ It’s a chromium web runtime that can be packaged with the app, so you get a benefit on 4.x devices, not just kitkat. It has more features (like webrtc) and sometimes outperforms chromium webview.
https://crosswalk-project.org/
============== https://gist.github.com/butelo/9365587
1:R.layout.activity_xwalk_embed_lib -> R.layout.xxxxx 2: R.menu.xwalk_embed_lib -> R.menu.xxxx 3: AndroidManifest.xml
============== use this https://groups.google.com/forum/#!msg/adt-dev/nQobKd2Gl_8/Z5yWAvCh4h4J
problem:libxwalkcore.so can be soft.
just do armeabi-v7a.jar is have lib/armeabi-v7a/libxwalkcore.