license: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Follow the instructions provided in the Android Plugins Guide for an overview of developing custom plugins.
To match the JavaScript interface‘s echo feature described in Application Plugins, use the plugin.xml
to inject a feature
specification to the local platform’s config.xml
file:
<platform name="amazon-fireos"> <config-file target="config.xml" parent="/*"> <feature name="Echo"> <param name="android-package" value="org.apache.cordova.plugin.Echo"/> </feature> </config-file> </platform>
Then add the following to the src/org/apache/cordova/plugin/Echo.java
file:
package org.apache.cordova.plugin; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CallbackContext; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /** * This class echoes a string called from JavaScript. */ public class Echo extends CordovaPlugin { @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("echo")) { String message = args.getString(0); this.echo(message, callbackContext); return true; } return false; } private void echo(String message, CallbackContext callbackContext) { if (message != null && message.length() > 0) { callbackContext.success(message); } else { callbackContext.error("Expected one non-empty string argument."); } } }
If you want to reuse Android Plugin code for the Amazon Fire OS platform then modify the plugin.xml to point to the android
specific source file. For example,
<platform name="amazon-fireos"> <config-file target="config.xml" parent="/*"> <feature name="Echo"> <param name="android-package" value="org.apache.cordova.plugin.Echo"/> </feature> </config-file> <source-file src="src/android/Echo.java" target-dir="src/org/apache/cordova/plugin" /> </platform>
If you want to write a customized plugin for the Amazon Fire OS platform then create a folder named amazon
under your plugin src/ folder and modify the plugin.xml to point to the amazon
specific source file. For example,
<platform name="amazon-fireos"> <config-file target="config.xml" parent="/*"> <feature name="Echo"> <param name="android-package" value="org.apache.cordova.plugin.Echo"/> </feature> </config-file> <source-file src="src/amazon/Echo.java" target-dir="src/org/apache/cordova/plugin" /> </platform>
Cordova for Amazon Fire OS makes use of custom Amazon WebView that is built on the open-source Chromium project. It is GPU accelerated and optimized for fluid performance on Kindle Fire.
To understand how to best use Amazon WebView in your project, check out the Amazon Developer Portal.