Amazon Fire OS Webansichten für
Beginnend mit 3.0.0, können Sie Cordova als Komponente in Amazon-Feuer-OS-Anwendungen. Amazon Fire OS bezieht sich auf diese Komponente als CordovaWebView
. CordovaWebView
erweitert Amazon WebView, die auf der open-Source-Projekt Chromium basiert. Durch die Nutzung dieser Funktion, können Ihre Webanwendungen der neuesten HTML5-Web-Standards, die in einem modernen Web-Runtime-Engine ausgeführt nutzen.
Voraussetzungen
Cordova 3.0.0 oder größer
Android SDK aktualisiert, um neuesten SDK
Amazon WebView SDK
Anleitung zur Verwendung von CordovaWebView in einem Amazon-Feuer-OS-Projekt
Download Amazon WebView SDK zu erweitern, und kopieren Sie die awv_interface.jar in
/framework/libs
Verzeichnis. Erstellen einer Libs / Ordner, wenn es nicht vorhanden ist.cd
in/framework
undant jar
baut die Cordova-Jar. Es schafft die .jar-Datei alscordova-x.x.x.jar
in das/framework
Verzeichnis.Bearbeiten der Anwendung
main.xml
Datei (unter/res/layout
) mit folgenden Aussehen derlayout_height
,layout_width
undid
Ihrer Anwendung angepasst:<org.apache.cordova.CordovaWebView android:id="@+id/tutorialView" android:layout_width="match_parent" android:layout_height="match_parent" />
Ihre Aktivität ändern, sodass es implementiert die
CordovaInterface
. Sie sollten die enthaltenen Methoden implementieren. Vielleicht möchten Sie Kopieren von/framework/src/org/apache/cordova/CordovaActivity.java
, oder setzen sie auf eigene Faust. Das folgende Codefragment zeigt eine einfache Anwendung, die die Schnittstelle verwendet. Beachten Sie, wie die referenzierten anzeigen-Id entspricht derid
in das XML-Fragment oben angegebene Attribut: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()); }
Wenn Sie die Kamera verwenden, sollten Sie dies auch implementieren:
@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);
}
}
Denken Sie daran, den Threadpool hinzufügen, sonst die Plugins keine Threads ausgeführt:
@Override
public ExecutorService getThreadPool() {
return threadPool;
}
Kopieren Sie Ihre Anwendung HTML und JavaScript-Dateien zu Ihrem Amazon-Feuer-OS-Projekts
/assets/www
Verzeichnis.Kopie
config.xml
von/framework/res/xml
zu Ihrem Projekts/res/xml
Verzeichnis.