* * *

Author Topic: Support for AdMob!  (Read 521 times)

TR3E

  • New member
  • *
  • Posts: 8
Support for AdMob!
« on: July 05, 2018, 08:18:01 am »
Hi guys, I've managed to support AdMob on LAMW. This mode:

First we need download: gradle 4.1 https://gradle.org/next-steps/?version=4.1&format=bin and install.

Second, we need to create a appCompat gradle project, and set the path of Gradle [LAMW] Android Module Wizard -> Paths Settings

Three, install the SDK components for AdMob:
Android Support Repository - Google Play services -  Google Repository

Fourth, add "compile 'com.google.android.gms: play-services-ads: 11.0.4'" to the project file "buidl.gradle"

Fifth, add the following code in the "Controls.java" file in the "jForm" class in the constructor:

Code: Java  [Select]
  1.         import com.google.android.gms.ads.AdRequest;
  2.         import com.google.android.gms.ads.AdView;
  3.         import com.google.android.gms.ads.MobileAds;
  4.         import com.google.android.gms.ads.AdSize;
  5.  
  6.         // ..... constructor
  7.  
  8.         String banner_id = "ca-app-pub-3940256099942544/6300978111";
  9.  
  10.         MobileAds.initialize(controls.activity, banner_id);
  11.  
  12.         LayoutParams bannerLParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
  13.                                               ViewGroup.LayoutParams.WRAP_CONTENT);
  14.  
  15.         bannerLParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
  16.         bannerLParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
  17.  
  18.         AdView adView=new AdView(controls.activity);
  19.         adView.setLayoutParams(bannerLParams);
  20.         adView.setAdSize(AdSize.BANNER);
  21.         adView.setAdUnitId(banner_id);
  22.         layout.addView(adView);
  23.  
  24.         //AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
  25.         AdRequest adRequest = new AdRequest.Builder().build();
  26.  
  27.         // Start loading the ad in the background.
  28.        adView.loadAd(adRequest);

Attached AdMob component and modifications in the latest version of LAMW.
« Last Edit: July 09, 2018, 08:19:05 am by tr3e »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1143
Re: Support for AdMob!
« Reply #1 on: July 05, 2018, 04:49:43 pm »

Hi tr3e!

Great Work!

Congratulations!

I will commit your solutions to github!

Thank you!!!!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

lainz

  • Hero Member
  • *****
  • Posts: 2769
  • I'm coding :)
    • Lainz
Re: Support for AdMob!
« Reply #2 on: July 05, 2018, 04:54:11 pm »
Thankyou, this is really good news  :)

jmpessoa

  • Hero Member
  • *****
  • Posts: 1143
Re: Support for AdMob!
« Reply #3 on: July 09, 2018, 03:07:54 am »

Hi all!

Please, someone can convert "admod.rar" to "admod.zip"  ...  ;D  O:-)

Thanks.
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

engkin

  • Hero Member
  • *****
  • Posts: 2017
Re: Support for AdMob!
« Reply #4 on: July 09, 2018, 03:11:33 am »

Hi all!

Please, someone can convert "admod.rar" to "admod.zip"  ...  ;D  O:-)

Thanks.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1143
Re: Support for AdMob!
« Reply #5 on: July 09, 2018, 03:16:53 am »

@engkin,

its working!

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

TR3E

  • New member
  • *
  • Posts: 8
Re: Support for AdMob!
« Reply #6 on: July 13, 2018, 06:22:57 pm »
I have created an example of use for AdMob.

Thaddy

  • Hero Member
  • *****
  • Posts: 6342
Re: Support for AdMob!
« Reply #7 on: July 13, 2018, 06:47:27 pm »
I have created an example of use for AdMob.
I'd rather have the opposite: don't bother me with advertising or at least - the basic minimum - no targeted advertising. (Nobody wants that, only marketeers.)
Anyway I will find a way to make such code explode.
I am enjoining wine, not whine....

TR3E

  • New member
  • *
  • Posts: 8
Re: Support for AdMob!
« Reply #8 on: July 13, 2018, 07:07:09 pm »
I have created an example of use for AdMob.
I'd rather have the opposite: don't bother me with advertising or at least - the basic minimum - no targeted advertising. (Nobody wants that, only marketeers.)
Anyway I will find a way to make such code explode.

You yourself, I simply give you the option. If you want to take it and if not.

I do not like publicity either, nor many things of this life. But you have to do everything in life.

And if not, look at the bottom of the page and see this advertising.
« Last Edit: July 13, 2018, 07:09:03 pm by tr3e »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus