Let’s simply comply with these few steps.
What’s the one factor each developer needs? More screens! Enhance your coding expertise with an exterior monitor to extend display screen actual property.
Install the Native Android SDK
Download the Android Admob SDK, extract it and replica
GoogleAdMobAdsSdk-*.*.*.jar to the PhoneGap venture’s
Now refresh your venture listing in Eclipse and add the newly downloaded SDK’s jar file to the venture’s construct path. You can do that by following these easy steps:
Include Admob’s Library
Add the next strains in your
MainActivity.java proper under different imports.
Here, the primary import comprises the capabilities associated to advertisements whereas the second will assist us in inserting the advertisements into the display screen.
Configure your AdMob advert unit ID
Now, inside the principle class of your
MainActivity.java file, create a brand new non-public string
AdMob_Ad_Unit like this:
Make certain to interchange
xxxxxxxxxxxxxxx with your individual ID as placing incorrect ID there’ll end in no advertisements displaying up. Now we’re prepared to indicate the advertisements in our app!
Create the Ad View
Below the newly added string, add yet another non-public variable
advertView of AdView sort like this:
This would be the container for the advert. Now, contained in the
onCreate operate, add the next strains on the backside:
This ought to be sufficient for the advertisements to indicate up in an actual system. However, if you wish to take a look at the advertisements on a Android Virtual Machine, you then’ll have so as to add this line above
advertView.loadAd(request); and advertisements will begin displaying up within the AVDs.
Make certain to remark out the above added line earlier than publishing the app for apparent causes!
So all the code file ought to appear like this:
The final step is to outline the newly created Ads exercise into the
AndroidManifest.xml file. Add this line in your manifest file after the closing tag of your foremost exercise.
Now you will need to be capable to see the advertisements when operating the app in an emulator or on an actual system. If you run into an issue or doesn’t get it to work then drop us a remark right here and we’ll show you how to! 🙂