Amazon Fire OS WebViews
Beginning with 3.0.0, you can use Cordova as a component in Amazon Fire OS applications. Amazon Fire OS refers to this component as CordovaWebView. CordovaWebView extends Amazon WebView that is built on the open source Chromium Project. By leveraging this feature, your web apps can utilize the latest HTML5 web standards running in a modern web runtime engine.
Prerequisites
Cordova 3.0.0 or greater
Android SDK updated to the latest SDK
Amazon WebView SDK
Guide to using CordovaWebView in a Amazon Fire OS Project
Download and expand the Amazon WebView SDK , then copy the awv_interface.jar into
/framework/libsdirectory. Create a libs/ folder if it doesn't exist.cdinto/frameworkand runant jarto build the cordova jar. It creates the .jar file formed ascordova-3.4.0.jarin the/frameworkdirectory.-
Edit your application's
main.xmlfile (under/res/layout) to look like the following, with thelayout_height,layout_widthandidmodified to suit your application:<org.apache.cordova.CordovaWebView android:id="@+id/tutorialView" android:layout_width="match_parent" android:layout_height="match_parent" /> -
Modify your activity so that it implements the
CordovaInterface. You should implement the included methods. You may wish to copy them from/framework/src/org/apache/cordova/CordovaActivity.java, or implement them on your own. The code fragment below shows a basic application that uses the interface. Note how the referenced view id matches theidattribute specified in the XML fragment shown above: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()); }
If you use the camera, you should also implement this:
@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);
}
}
Finally, remember to add the thread pool, otherwise the plugins have no threads to run on:
@Override
public ExecutorService getThreadPool() {
return threadPool;
}
Copy your application's HTML and JavaScript files to your Amazon Fire OS project's
/assets/wwwdirectory.Copy
config.xmlfrom/framework/res/xmlto your project's/res/xmldirectory.