@@ -0,0 +1,2394 @@
+package com.quantumrand.amazonAdsPlugin;%0A%0Aimport org.apache.cordova.CallbackContext;%0Aimport org.apache.cordova.CordovaPlugin;%0Aimport org.json.JSONArray;%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0A%0Aimport android.view.ViewGroup;%0A%0Aimport com.amazon.device.ads.AdLayout;%0Aimport com.amazon.device.ads.AdRegistration;%0A%0A%0Apublic class AmazonAdsPlugin extends CordovaPlugin%7B%0A%09public AdLayout adView;%0A%09public static final String ACTION_DISPLAY_AMAZON_ADS = %22displayAmazonAds%22;%0A%09%0A%09%0A%09@Override%0A%09public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException %7B%0A%09%09%0A%09%09if (ACTION_DISPLAY_AMAZON_ADS.equals(action)) %7B%0A%09%09%09JSONObject arg_object;%0A%09%09%09arg_object = args.getJSONObject(0);%0A%09%09%09displayAmazonAds(arg_object, callbackContext);%0A%09%09%09return true;%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09callbackContext.error(%22Invalid action%22);%0A%09%09    return false;%0A%09%09%7D%0A%09%09%0A%09%7D%0A%09%0A%09private void displayAmazonAds(JSONObject args_object, final CallbackContext callbackContext)%7B%0A%09%09%0A%09%09%0A%09%09adView = (AdLayout) new AdLayout(this.cordova.getActivity());%0A%09%09final boolean debug;%0A%09%09final boolean isOnTop;%0A%09%09final String appKey;%0A%09%09try %7B%0A%09%09%09debug = args_object.getBoolean(%22debug%22);%0A%09%09%09isOnTop = args_object.getBoolean(%22isOnTop%22);%0A%09%09%09appKey = args_object.getString(%22appKey%22);%0A%09%09%7D catch (JSONException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09callbackContext.error(e.getMessage());%0A%09%09%09e.printStackTrace();%0A%09%09%09return;%0A%09%09%7D%0A%09%09cordova.getActivity().runOnUiThread(new Runnable() %7B%0A            public void run() %7B%0A            %09%0A            %0A%09%09%09%09// For debugging purposes enable logging, but disable for production builds.%0A%09%09        AdRegistration.enableLogging(debug);%0A%09%09        // For debugging purposes flag all ad requests as tests, but set to false for production builds.%0A%09%09        AdRegistration.enableTesting(debug);%0A%09%09        // Register Application Key%0A%09%09        AdRegistration.setAppKey(appKey);%0A%09%09        %0A%09%09        if (adView.getParent() != null) %7B%09%09%09%09%09%09%09//check for existing ad%0A%09%09            ((ViewGroup)adView.getParent()).removeView(adView); %0A%09%09        %7D%0A%09%09        ViewGroup parentView = (ViewGroup) webView.getParent();%0A%09%09        if (isOnTop) %7B%0A%09%09            parentView.addView(adView, 0);%0A%09%09        %7D else %7B%0A%09%09            parentView.addView(adView);%0A%09%09        %7D%0A%09%09        %0A%09%09        adView.loadAd();%0A%09%09        callbackContext.success(); // Thread-safe.%0A%09%09        %0A            %7D%0A%09%09%0A%09%09%7D);%0A%09%7D%0A%7D%0A

Create AmazonAdsPlugin.java