Page 2 of 3

could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Fri Dec 20, 2013 1:50 pm
by Domenico Dattilo

Dear Maryna I attach the comment from AdMob
sorry for troubling you but I am to first experiences

"To display the banner in your application, follow the instructions detailed on the integration of the SDK and sample code for creating a banner. You can also download a sample project that explains how to integrate AdMob ads in your application.
To view the report data based on the position, be sure to use the ID of the ad units below when creating an ad request.
Application Name: Ricette Paesane
Name ad unit: Ricette banner
Ad Unit ID: ca-app-pub-6108627909421680/7205955851
Check out our forum if you have questions on how to integrate AdMob SDK into your application.
Sincerely,
The support team of AdMob"


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Fri Dec 20, 2013 3:17 pm
by Kateryna Grynko

Hi Domenico,

You can use AdMob PhoneGap plug-in to integrate: https://getsatisfaction.com/apperyio/...


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Fri Dec 20, 2013 5:50 pm
by Domenico Dattilo

Sorry Katya but I don't understant very well..
I think that I must to export the app to the eclipse project and put the bunner. is it correct ?
thanks


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Fri Dec 20, 2013 6:05 pm
by Kateryna Grynko

Domenico,

I suppose this can be done within Appery.io. Please take a look at the code I suggested. You can add this plug-in as JavaScript.


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Sat Dec 21, 2013 7:21 pm
by Domenico Dattilo

Dear Katya,
I try yuor suggestion but with negative result.
Can you help me again ?
thanks


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Sun Dec 22, 2013 1:22 am
by maxkatz

Can you show us what exactly you tried and what doesn't work?


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Sun Dec 22, 2013 9:20 am
by Domenico Dattilo

Hello Max,
sorry but I read the suggestion mentioned but I don't understand what I must to do for insert the bunner.
I must to refresh the apper.io project to ECLIPSE ?
or I must to insert the instruction in appery.io project ? where ?
Do you have some example ?
thanks


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Sun Dec 22, 2013 9:57 am
by Igor

Hello,

You can use Appery,io builder to add AdMob PhoneGap, you don't need to export project to Eclipse. Below doc will show you how to do this:
http://docs.appery.io/documentation/u...


could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Mon Dec 23, 2013 5:33 pm
by Domenico Dattilo

Having said that I'm not a programmer
I'm sorry but I can not figure out how to insert a banner ad. I followed your instructions. I have added :

Code: Select all

 file": "plugins\\com.phonegap.plugins.banner\\www\\banner.js", 
     "id": "com.phonegap.plugins.banner", 
     "clobbers": [ 
         "banner" 

and after

Code: Select all

   param name="android-package" value="com.phonegap.plugins.banner.banner"  

I have added the js and java and after in the project I added javascript
file js

/**

  • This class defines an AdMob object that is used to show ads natively in a

  • native iOS application.

  • @constructor
    */
    var admob = {
    /**

    • This enum represents AdMob's supported ad sizes. Use one of these

      • constants as the adSize when calling createBannerView.

      • BANNER 320x50 Standard Banner Phones and Tablets

      • IAB_MRECT 300x250 IAB Medium Rectangle Tablets

      • IAB_BANNER 468x60 IAB Full-Size Banner Tablets

      • IAB_LEADERBOARD 728x90 IAB Leaderboard Tablets

      • SMART_BANNER url Smart Banner Phones and Tablets

      • https://developers.google.com/mobile-...
        *

      • @const
        */
        AD_SIZE : {
        BANNER: "BANNER",
        IAB_MRECT: "IAB_MRECT",
        IAB_BANNER: "IAB_BANNER",
        IAB_LEADERBOARD: "IAB_LEADERBOARD",
        SMART_BANNER: "SMART_BANNER"
        },

        /**

      • Creates a new AdMob banner view.
        *

      • @param {!Object} options The options used to create a banner. They should

      • be specified similar to the following.
        *

      • {

      • 'publisherId': 'MY_PUBLISHER_ID',

      • 'adSize': AdMob.AD_SIZE.AD_SIZE_CONSTANT,

      • 'positionAtTop': false

      • }
        *

      • publisherId is the publisher ID from your AdMob site, adSize

      • is one of the AdSize constants, and positionAtTop is a boolean to

      • determine whether to create the banner above or below the app content.

      • A publisher ID and AdSize are required. The default for postionAtTop

      • is false, meaning the banner would be shown below the app content.

      • @param {function()} successCallback The function to call if the banner was

      • created successfully.

      • @param {function()} failureCallback The function to call if create banner

      • was unsuccessful.
        */
        createBannerView : function (options, successCallback, failureCallback) {
        var defaults = {
        'publisherId': undefined,
        'adSize': undefined,
        'positionAtTop': false
        };
        var requiredOptions = ['publisherId', 'adSize'];

        // Merge optional settings into defaults.
        for (var key in defaults) {
        if (typeof options[key] !== 'undefined') {
        defaults[key] = options[key];
        }
        }

        // Check for and merge required settings into defaults.
        requiredOptions.forEach(function(key) {
        if (typeof options[key] === 'undefined') {
        failureCallback('Failed to specify key: ' + key + '.');
        return;
        }
        defaults[key] = options[key];
        });

        cordova.exec(
        successCallback,
        failureCallback,
        'AdMobPlugin',
        'createBannerView',
        [{publisherId:defaults['publisherId'], adSize:defaults['adSize'], positionAtTop:defaults['positionAtTop']}]
        );
        },

        /**

      • Creates a new AdMob interstitial view.

      • https://developers.google.com/mobile-...
        *

      • @param {!Object} options The options used to create a banner. They should

      • be specified similar to the following.
        *

      • {

      • 'publisherId': 'MY_PUBLISHER_ID'

      • }
        *

      • publisherId is the publisher ID from your AdMob site, adSize

      • is one of the AdSize constants, and positionAtTop is a boolean to

      • determine whether to create the banner above or below the app content.

      • A publisher ID and AdSize are required. The default for postionAtTop

      • is false, meaning the banner would be shown below the app content.

      • @param {function()} successCallback The function to call if the banner was

      • created successfully.

      • @param {function()} failureCallback The function to call if create banner

      • was unsuccessful.
        */
        createInterstitialView : function (options, successCallback, failureCallback) {
        var defaults = {
        'publisherId': undefined
        };
        var requiredOptions = ['publisherId'];

        // Merge optional settings into defaults.
        for (var key in defaults) {
        if (typeof options[key] !== 'undefined') {
        defaults[key] = options[key];
        }
        }

        // Check for and merge required settings into defaults.
        requiredOptions.forEach(function(key) {
        if (typeof options[key] === 'undefined') {
        failureCallback('Failed to specify key: ' + key + '.');
        return;
        }
        defaults[key] = options[key];
        });

        cordova.exec(
        successCallback,
        failureCallback,
        'AdMobPlugin',
        'createInterstitialView',
        [{publisherId:defaults['publisherId']}]
        );
        },

        /**

      • Request an AdMob ad. This call should not be made until after the banner

      • view has been successfully created.
        *

      • @param {!Object} options The options used to request an ad. They should

      • be specified similar to the following.
        *

      • {

      • 'isTesting': true|false,

      • 'extras': {

      • 'key': 'value'

      • }

      • }
        *

      • isTesting is a boolean determining whether or not to request a

      • test ad on an emulator, and extras represents the extras to pass

      • into the request. If no options are passed, the request will have

      • testing set to false and an empty extras.

      • @param {function()} successCallback The function to call if an ad was

      • requested successfully.

      • @param {function()} failureCallback The function to call if an ad failed

      • to be requested.
        */
        requestAd : function(options, successCallback, failureCallback) {
        var defaults = {
        'isTesting': false,
        'extras': {}
        };

        for (var key in defaults) {
        if (typeof options[key] !== 'undefined') {
        defaults[key] = options[key];
        }
        }

        cordova.exec(
        successCallback,
        failureCallback,
        'AdMobPlugin',
        'requestAd',
        [{isTesting:defaults['isTesting'], extras:defaults['extras']}]
        );
        },

        /**

      • kill banner.

      • @param {function()} successCallback The function to call if an ad was

      • requested successfully.

      • @param {function()} failureCallback The function to call if an ad failed

      • to be requested.
        */
        killAd : function(successCallback, failureCallback) {
        cordova.exec(
        successCallback,
        failureCallback,
        'AdMobPlugin',
        'killAd',[{}]);
        }

    };

    module.exports = admob;

    file JAVA:

    package com.google.cordova.plugin;

    import java.util.Iterator;

    import org.apache.cordova.CallbackContext;
    import org.apache.cordova.CordovaInterface;
    import org.apache.cordova.CordovaPlugin;
    import org.apache.cordova.LinearLayoutSoftKeyboardDetect;
    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;

    import android.util.Log;

    import com.google.ads.Ad;
    import com.google.ads.AdListener;
    import com.google.ads.AdRequest;
    import com.google.ads.AdRequest.ErrorCode;
    import com.google.ads.AdSize;
    import com.google.ads.doubleclick.DfpAdView;
    import com.google.ads.doubleclick.DfpInterstitialAd;
    import com.google.ads.mediation.admob.AdMobAdapterExtras;

    /**

  • This class represents the native implementation for the AdMob Cordova plugin.

  • This plugin can be used to request AdMob ads natively via the Google AdMob

  • SDK. The Google AdMob SDK is a dependency for this plugin.
    */
    public class AdMobPlugin extends CordovaPlugin {
    /** The adView to display to the user. */
    private DfpAdView adView;
    private DfpInterstitialAd intertitial;

    Code: Select all

     /** Whether or not the ad should be positioned at top or bottom of screen. */ 
     private boolean positionAtTop; 
    
     /** Common tag used for logging statements. */ 
     private static final String LOGTAG = "AdMobPlugin"; 
    
     /** Cordova Actions. */ 
     public static final String ACTION_CREATE_BANNER_VIEW = "createBannerView"; 
     public static final String ACTION_CREATE_INTERSTITIAL_VIEW = "createInterstitialView"; 
     public static final String ACTION_REQUEST_AD = "requestAd"; 
     public static final String KILL_AD = "killAd"; 
    
     /** 
      * This is the main method for the AdMob plugin. All API calls go through 
      * here. This method determines the action, and executes the appropriate 
      * call. 
      *  
      * @param action 
      *            The action that the plugin should execute. 
      * @param inputs 
      *            The input parameters for the action. 
      * @param callbackId 
      *            The callback ID. This is currently unused. 
      * @return A PluginResult representing the result of the provided action. A 
      *         status of INVALID_ACTION is returned if the action is not 
      *         recognized. 
      */ 
     @Override 
     public boolean execute(String action, JSONArray inputs, 
                     CallbackContext callbackContext) throws JSONException { 
             if (ACTION_CREATE_BANNER_VIEW.equals(action)) { 
                     executeCreateBannerView(inputs, callbackContext); 
                     return true; 
             } else if (ACTION_CREATE_INTERSTITIAL_VIEW.equals(action)) { 
                     executeCreateInterstitialView(inputs, callbackContext); 
                     return true; 
             } else if (ACTION_REQUEST_AD.equals(action)) { 
                     executeRequestAd(inputs, callbackContext); 
                     return true; 
             } else if (KILL_AD.equals(action)) { 
                     executeKillAd(callbackContext); 
                     return true; 
             } else { 
                     Log.d(LOGTAG, String.format("Invalid action passed: %s", action)); 
                     callbackContext.error("Invalid Action"); 
             } 
             return false; 
     } 
    
     /** 
      * Parses the create banner view input parameters and runs the create banner 
      * view action on the UI thread. If this request is successful, the 
      * developer should make the requestAd call to request an ad for the banner. 
      *  
      * @param inputs 
      *            The JSONArray representing input parameters. This function 
      *            expects the first object in the array to be a JSONObject with 
      *            the input parameters. 
      * @return A PluginResult representing whether or not the banner was created 
      *         successfully. 
      */ 
     private void executeCreateBannerView(JSONArray inputs, CallbackContext callbackContext) { 
             String publisherId = ""; 
             String size = ""; 
    
             // Get the input data. 
             try { 
                     JSONObject data = inputs.getJSONObject(0); 
                     publisherId = data.getString("publisherId"); 
                     size = data.getString("adSize"); 
                     this.positionAtTop = data.getBoolean("positionAtTop"); 
                     Log.w(LOGTAG, "executeCreateBannerView OK"); 
                     Log.w(LOGTAG, "size: " + size); 
                     Log.w(LOGTAG, "publisherId: " + publisherId); 
                     Log.w(LOGTAG, "positionAtTop: " + (this.positionAtTop ? "true" : "false")); 
             } catch (JSONException exception) { 
                     Log.w(LOGTAG, 
                                     String.format("Got JSON Exception: %s", 
                                                     exception.getMessage())); 
                     callbackContext.error(exception.getMessage()); 
             } 
             AdSize adSize = adSizeFromSize(size); 
             createBannerView(publisherId, adSize, callbackContext); 
     } 
    
     private synchronized void createBannerView(final String publisherId, 
                     final AdSize adSize, final CallbackContext callbackContext) { 
             final CordovaInterface cordova = this.cordova; 
    
             // Create the AdView on the UI thread. 
             Log.w(LOGTAG, "createBannerView"); 
             Runnable runnable = new Runnable() { 
                     public void run() { 
                             Log.w(LOGTAG, "run"); 
                             Log.w(LOGTAG, String.valueOf(webView)); 
                             // Log.w(LOGTAG, "adSize::" + adSize); calling adSize.toString() with SmartBanner == crash 
                             if (adSize == null) { 
                                     callbackContext 
                                                     .error("AdSize is null. Did you use an AdSize constant?"); 
                                     return; 
                             } else { 
                                     adView = new DfpAdView(cordova.getActivity(), adSize, 
                                                     publisherId); 
                                     adView.setAdListener(new BannerListener()); 
                                     LinearLayoutSoftKeyboardDetect parentView = (LinearLayoutSoftKeyboardDetect) webView 
                                                     .getParent(); 
                                     if (positionAtTop) { 
                                             parentView.addView(adView, 0); 
                                     } else { 
                                             parentView.addView(adView); 
                                     } 
                                     // Notify the plugin. 
                                     callbackContext.success(); 
                             } 
                     } 
             }; 
             this.cordova.getActivity().runOnUiThread(runnable); 
     } 
    
     /** 
      * Parses the create banner view input parameters and runs the create banner 
      * view action on the UI thread. If this request is successful, the 
      * developer should make the requestAd call to request an ad for the banner. 
      *  
      * @param inputs 
      *            The JSONArray representing input parameters. This function 
      *            expects the first object in the array to be a JSONObject with 
      *            the input parameters. 
      * @return A PluginResult representing whether or not the banner was created 
      *         successfully. 
      */ 
     private void executeCreateInterstitialView(JSONArray inputs, CallbackContext callbackContext) { 
             String publisherId = ""; 
    
             // Get the input data. 
             try { 
                     JSONObject data = inputs.getJSONObject(0); 
                     publisherId = data.getString("publisherId"); 
                     Log.w(LOGTAG, "executeCreateInterstitialView OK"); 
             } catch (JSONException exception) { 
                     Log.w(LOGTAG, String.format("Got JSON Exception: %s", exception.getMessage())); 
                     callbackContext.error(exception.getMessage()); 
             } 
             createInterstitialView(publisherId, callbackContext); 
     } 
    
     private synchronized void createInterstitialView(final String publisherId, final CallbackContext callbackContext) { 
             final CordovaInterface cordova = this.cordova; 
    
             // Create the AdView on the UI thread. 
             Log.w(LOGTAG, "createInterstitialView"); 
             Runnable runnable = new Runnable() { 
                     public void run() { 
                             intertitial = new DfpInterstitialAd(cordova.getActivity(), publisherId); 
                             intertitial.setAdListener(new BannerListener()); 
                             // Notify the plugin. 
                             callbackContext.success(); 
                     } 
             }; 
             this.cordova.getActivity().runOnUiThread(runnable); 
     } 
    
     /** 
      * Parses the request ad input parameters and runs the request ad action on 
      * the UI thread. 
      *  
      * @param inputs 
      *            The JSONArray representing input parameters. This function 
      *            expects the first object in the array to be a JSONObject with 
      *            the input parameters. 
      * @return A PluginResult representing whether or not an ad was requested 
      *         succcessfully. Listen for onReceiveAd() and onFailedToReceiveAd() 
      *         callbacks to see if an ad was successfully retrieved. 
      */ 
     private void executeRequestAd(JSONArray inputs, 
                     CallbackContext callbackContext) { 
             boolean isTesting = false; 
             JSONObject inputExtras = null; 
    
             // Get the input data. 
             try { 
                     JSONObject data = inputs.getJSONObject(0); 
                     isTesting = data.getBoolean("isTesting"); 
                     inputExtras = data.getJSONObject("extras"); 
                     Log.w(LOGTAG, "executeRequestAd OK"); 
                     // callbackContext.success(); 
                     // return true; 
             } catch (JSONException exception) { 
                     Log.w(LOGTAG, 
                                     String.format("Got JSON Exception: %s", 
                                                     exception.getMessage())); 
                     callbackContext.error(exception.getMessage()); 
             } 
    
             // Request an ad on the UI thread. 
             if (adView != null) { 
                     requestAd(isTesting, inputExtras, callbackContext); 
             } else if (intertitial != null) { 
                     requestIntertitial(isTesting, inputExtras, callbackContext); 
             } else { 
                     callbackContext 
                                     .error("adView && intertitial are null. Did you call createBannerView?"); 
                     return; 
             } 
     } 
    
     private synchronized void requestIntertitial(final boolean isTesting, 
                     final JSONObject inputExtras, final CallbackContext callbackContext) { 
             Log.w(LOGTAG, "requestIntertitial"); 
             // Create the AdView on the UI thread. 
             Runnable runnable = new Runnable() { 
                     @SuppressWarnings("unchecked") 
                     public void run() { 
                             if (intertitial == null) { 
                                     callbackContext 
                                                     .error("intertitial is null. Did you call createBannerView?"); 
                                     return; 
                             } else { 
                                     AdRequest request = new AdRequest(); 
                                     if (isTesting) { 
                                             // This will request test ads on the emulator only. You 
                                             // can 
                                             // get your 
                                             // hashed device ID from LogCat when making a live 
                                             // request. 
                                             // Pass 
                                             // this hashed device ID to addTestDevice request test 
                                             // ads 
                                             // on your 
                                             // device. 
                                             request.addTestDevice(AdRequest.TEST_EMULATOR); 
                                     } 
                                     AdMobAdapterExtras extras = new AdMobAdapterExtras(); 
                                     Iterator extrasIterator = inputExtras.keys(); 
                                     boolean inputValid = true; 
                                     while (extrasIterator.hasNext()) { 
                                             String key = extrasIterator.next(); 
                                             try { 
                                                     extras.addExtra(key, inputExtras.get(key)); 
                                             } catch (JSONException exception) { 
                                                     Log.w(LOGTAG, String.format( 
                                                                     "Caught JSON Exception: %s", 
                                                                     exception.getMessage())); 
                                                     callbackContext.error("Error grabbing extras"); 
                                                     inputValid = false; 
                                             } 
                                     } 
                                     if (inputValid) { 
                                             // extras.addExtra("cordova", 1); 
                                             // request.setNetworkExtras(extras); 
                                             intertitial.loadAd(request); 
                                             // Notify the plugin. 
                                             callbackContext.success(); 
                                     } 
                             } 
                     } 
             }; 
             this.cordova.getActivity().runOnUiThread(runnable); 
     } 
    
     private synchronized void requestAd(final boolean isTesting, 
                     final JSONObject inputExtras, final CallbackContext callbackContext) { 
             Log.w(LOGTAG, "requestAd"); 
             // Create the AdView on the UI thread. 
             Runnable runnable = new Runnable() { 
                     @SuppressWarnings("unchecked") 
                     public void run() { 
                             if (adView == null) { 
                                     callbackContext 
                                                     .error("AdView is null.  Did you call createBannerView?"); 
                                     return; 
                             } else { 
                                     AdRequest request = new AdRequest(); 
                                     if (isTesting) { 
                                             // This will request test ads on the emulator only. You 
                                             // can 
                                             // get your 
                                             // hashed device ID from LogCat when making a live 
                                             // request. 
                                             // Pass 
                                             // this hashed device ID to addTestDevice request test 
                                             // ads 
                                             // on your 
                                             // device. 
                                             request.addTestDevice(AdRequest.TEST_EMULATOR); 
                                     } 
                                     AdMobAdapterExtras extras = new AdMobAdapterExtras(); 
                                     Iterator extrasIterator = inputExtras.keys(); 
                                     boolean inputValid = true; 
                                     while (extrasIterator.hasNext()) { 
                                             String key = extrasIterator.next(); 
                                             try { 
                                                     extras.addExtra(key, inputExtras.get(key)); 
                                             } catch (JSONException exception) { 
                                                     Log.w(LOGTAG, String.format( 
                                                                     "Caught JSON Exception: %s", 
                                                                     exception.getMessage())); 
                                                     callbackContext.error("Error grabbing extras"); 
                                                     inputValid = false; 
                                             } 
                                     } 
                                     if (inputValid) { 
                                             // extras.addExtra("cordova", 1); 
                                             // request.setNetworkExtras(extras); 
                                             adView.loadAd(request); 
                                             // Notify the plugin. 
                                             callbackContext.success(); 
                                     } 
                             } 
                     } 
             }; 
             this.cordova.getActivity().runOnUiThread(runnable); 
     } 
    
     private void executeKillAd(final CallbackContext callbackContext) { 
             final Runnable runnable = new Runnable() { 
                         public void run() { 
                             if (adView == null) { 
                                 // Notify the plugin. 
                                         callbackContext.error("AdView is null.  Did you call createBannerView or already destroy it?"); 
                             } else { 
                                         LinearLayoutSoftKeyboardDetect parentView = (LinearLayoutSoftKeyboardDetect) webView 
                                                     .getParent(); 
                                 parentView.removeView(adView); 
                                 adView.removeAllViews(); 
                                 adView.destroy(); 
                                 adView = null; 
                                 callbackContext.success(); 
                             } 
                         } 
             }; 
    
             this.cordova.getActivity().runOnUiThread(runnable); 
     } 
    
     /** 
      * This class implements the AdMob ad listener events. It forwards the 
      * events to the JavaScript layer. To listen for these events, use: 
      *  
      * document.addEventListener('onReceiveAd', function()); 
      * document.addEventListener('onFailedToReceiveAd', function(data)); 
      * document.addEventListener('onPresentScreen', function()); 
      * document.addEventListener('onDismissScreen', function()); 
      * document.addEventListener('onLeaveApplication', function()); 
      */ 
     private class BannerListener implements AdListener { 
    
             @Override 
             public void onReceiveAd(Ad ad) { 
                     if (ad == intertitial) { 
                             intertitial.show(); 
                     } 
                     webView.loa

could you please let me know if is it possible to Blank a label after to have insert the value with bottom ?

Posted: Mon Dec 23, 2013 7:24 pm
by Maryna Brodina

Hello! Could you clarify are there any errors in console? How do you test app? What device/OS version you use?