Recent

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

TR3E

  • New member
  • *
  • Posts: 35
    • TR3E Software
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: 1208
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: 2921
    • Home
Re: Support for AdMob!
« Reply #2 on: July 05, 2018, 04:54:11 pm »
Thankyou, this is really good news  :)

jmpessoa

  • Hero Member
  • *****
  • Posts: 1208
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: 2134
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: 1208
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: 35
    • TR3E Software
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: 7195
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.
inline variables like in D10.3 are a bit like Brexit: if you are given the wrong information it sounds like a good idea. Every kid loves candy, but it makes you fat and your teeth will disappear.

TR3E

  • New member
  • *
  • Posts: 35
    • TR3E Software
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 »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1208
Re: Support for AdMob!
« Reply #9 on: August 01, 2018, 11:49:50 pm »

Hi TR3E!

the "AppAdMobDemo" is incomplete?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 1208
Re: Support for AdMob!
« Reply #10 on: August 05, 2018, 07:40:35 am »
Hi,  TR3E!

The "jsAdMob"  was added to LAMW git repository!

and the demo, too: "AppCompatAdMobDemo1"

Thank you!

PS. "js" is for "Android Bridges Support" component tab
[need "AppCompat" theme!!!]


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

TR3E

  • New member
  • *
  • Posts: 35
    • TR3E Software
Re: Support for AdMob!
« Reply #11 on: August 09, 2018, 11:31:55 am »
Ok thank you, great job.