アマゾン火 OS web 表示
3.3.0 以降、コルドバ アマゾン火 OS アプリケーションでコンポーネントとして使用できます。 アマゾン火 OS としてこのコンポーネントを指します CordovaWebView
。 CordovaWebView
オープン ソース クロム プロジェクトに組み込まれているアマゾン WebView を拡張します。 この機能を活用してあなたの web アプリは現代のウェブ ランタイム エンジンで実行される最新の HTML5 web 標準を利用できます。
アマゾン火 OS に精通している場合は、おく必要があります最初アマゾン火 OS プラットフォーム ガイドとは、WebView を埋め込みのより珍しい開発オプションを実行する前に、最新の Sdk でインストールしました。
前提条件
コルドバ 3.3.0 以上
最新の SDK を更新 android SDK
アマゾン WebView SDK
アマゾン火 OS プロジェクトで CordovaWebView の使用へのガイドします。
これらの指示に従う、最新コルドバ分布があることを確認します。Cordova.apache.orgからダウンロードし、そのアマゾン火 OS パッケージを解凍します。
ダウンロードアマゾン WebView SDKを展開しに awv_interface.jar をコピー
/framework/libs
ディレクトリ。 ライブラリを作成する/フォルダーが存在しない場合。パッケージに移動
/framework
ディレクトリと実行ant jar
。Cordova が作成されます.jar
として形成されたファイル/framework/cordova-x.x.x.jar
.コピー、
.jar
Android プロジェクトにファイル/libs
ディレクトリ。次に、アプリケーションの追加
/res/xml/main.xml
ファイルと、layout_height
、layout_width
とid
、アプリケーションに合うように変更します。<org.apache.cordova.CordovaWebView android:id="@+id/tutorialView" android:layout_width="match_parent" android:layout_height="match_parent" />
あなたの活動を変更して、それを実装する、
CordovaInterface
。 含まれているメソッドを実装する必要があります。 それらをコピーすることができます/framework/src/org/apache/cordova/CordovaActivity.java
、または独自に実装します。 インターフェイスを使用して、基本的なアプリケーションを次のコード片に示します。 参照先のビュー id と一致する方法に注意してください、id
上記のように XML フラグメントで指定された属性。public class CordovaViewTestActivity extends Activity implements CordovaInterface { CordovaWebView cwv; /* Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); cwv = (CordovaWebView) findViewById(R.id.tutorialView); Config.init(this); cwv.loadUrl(Config.getStartUrl()); }
カメラを使用する場合もこれを実装する必要があります。
@Override
public void setActivityResultCallback(CordovaPlugin plugin) {
this.activityResultCallback = plugin;
}
/**
* Launch an activity for which you would like a result when it finished. When this activity exits,
* your onActivityResult() method is called.
*
* @param command The command object
* @param intent The intent to start
* @param requestCode The request code that is passed to callback to identify the activity
*/
public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
this.activityResultCallback = command;
this.activityResultKeepRunning = this.keepRunning;
// If multitasking turned on, then disable it for activities that return results
if (command != null) {
this.keepRunning = false;
}
// Start activity
super.startActivityForResult(intent, requestCode);
}
@Override
/**
* Called when an activity you launched exits, giving you the requestCode you started it with,
* the resultCode it returned, and any additional data from it.
*
* @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult().
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
*/
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
CordovaPlugin callback = this.activityResultCallback;
if (callback != null) {
callback.onActivityResult(requestCode, resultCode, intent);
}
}
最後に、スレッド プールを追加してください、それ以外の場合、プラグインしているスレッド上で実行します。
@Override
public ExecutorService getThreadPool() {
return threadPool;
}
アプリケーションの HTML や JavaScript ファイル、プロジェクトにコピー アマゾン火 OS の
/assets/www
ディレクトリ。コピー
config.xml
から/framework/res/xml
プロジェクトの/res/xml
ディレクトリ。