Releases: amirisback/frogo-admob
Releases · amirisback/frogo-admob
Release v4.1.8
About This Project
- Available on Google Dev Library - Click Here
- Privacy Policy Click Here
- LICENSE Click Here
- Helper for activating admob
- Example Source Code For Call Method Show Admob
- Calling method on Inheritance Class
- Implement all Admob Version
- Jetpack Compose Function (Experimental)
- Don't forget implement frogo-sdk Click Here
Note For Jitpack Build
- Red : Failed (So don't use that version / Using previous version)
- Green : Success / Pass (Use It)
ScreenShot Apps
Banner and Interstitial | RecyclerView with Banner | Rewarded Apps |
---|---|---|
Version Release
$version_release = 4.1.8
What's New??
* Enhance Performance *
* Refactoring Code *
* Update Admob Library Version 20.6.0 *
* Update : Adding Function Request Admob From Server *
How To Use / Implement This Project
Step 1. Add the JitPack repository to your build file
<Option 1> Groovy Gradle
// Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
<Option 2> Kotlin DSL Gradle
// Add it in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}
Step 2. Add the dependency
<Option 1> Groovy
dependencies {
// library google ads
implementation 'com.google.android.gms:play-services-ads:${latest_version}'
// library frogo-admob-helper
implementation 'com.github.amirisback:frogo-admob:4.1.8'
}
<Option 2> Kotlin DSL
dependencies {
// library google ads
implementation("com.google.android.gms:play-services-ads:${latest_version}")
// library frogo-admob-helper
implementation("com.github.amirisback:frogo-admob:4.1.8")
}
Step 3. Adding meta-data on AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
Step 4. Setup Admob and Showing Ads
XML
Click for detail!
Setup Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
}
private fun setupAdmob(){
setApp()
setBanner()
setInterstitial()
setRewarded()
setRewardedInterstitial()
}
private fun setApp() {
setupAdsApp(getString(R.string.admob_app_id))
}
private fun setBanner() {
setupAdsBanner(getString(R.string.admob_banner))
}
private fun setInterstitial() {
// setupAdsInterstitial(getString(R.string.admob_interstitial))
}
private fun setRewarded() {
setupAdsRewarded(getString(R.string.admob_rewarded))
}
private fun setRewardedInterstitial() {
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial))
}
}
Showing Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
setupButtonClick()
setupBannerAds()
}
...
...
...
private fun setupBannerAds() {
setupShowAdsBannerContainer(
this,
AdSize.SMART_BANNER,
binding.includeAdsView.frogoAdsBanner
)
setupShowAdsBanner(binding.adsXml.adsPhoneTabSpecialSmartBanner)
}
private fun setupButtonClick() {
binding.apply {
btnInterstitial.setOnClickListener {
// setupShowAdsInterstitial()
val listener = object : IFrogoAdListener.Interstitial {
override fun onAdFailedToLoad(adError: LoadAdError) {
showToast("Gagal Iklan")
}
override fun onAdLoaded(interstitialAd: InterstitialAd) {
}
}
FrogoAdmob.Interstitial.setupInterstitial(this@MainActivity, "", listener)
FrogoAdmob.Interstitial.showInterstitial(this@MainActivity, listener)
}
btnRewarded.setOnClickListener {
setupShowAdsRewarded(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
btnRewardedInterstitial.setOnClickListener {
setupShowAdsRewardedInterstitial(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
}
}
}
Jetpack Compose
Click for detail!
ComposeActivity
class ComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
FrogoAdmobTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Column {
FrogoAdmobBannerView(
mAdUnitID = getString(R.string.admob_banner),
mAdSize = adsize_banner
)
}
}
}
}
}
}
Hybrid (Jetpack Compose + XML)
Click for detail!
XML Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mvvm.main.MainActivity">
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/include_ads_view"/>
<include
android:id="@+id/include_ads_view"
layout="@layout/ads_phone_tab_special_smart_banner" />
</RelativeLayout>
Kotlin Class
class HybridActivity : BaseActivity<ActivityHybridBinding>() {
override fun setupViewBinding(): ActivityHybridBinding {
return ActivityHybridBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.apply {
composeView.setContent {
Greeting("FrogoAdmob")
}
setupShowAdsBanner(includeAdsView.adsPhoneTabSpecialSmartBanner)
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
}
Java Sample Implementation
- You can follow sample below or go to Full Sample Code Full Code
Click for detail!
Setup Java BaseActivity
public abstract class <Your BaseJavaActivity> extends FrogoAdmobActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupAdmob();
}
private void setupAdmob(){
setApp();
setBanner();
setInterstitial();
setRewarded();
setRewardedInterstitial();
}
private void setApp() {
// Your App ID
setupAdsApp(getString(R.string.admob_app_id));
}
private void setBanner() {
// Your Banner ID
setupAdsBanner(getString(R.string.admob_banner));
}
private void setInterstitial() {
// Your Interstitial ID
setupAdsInterstitial(getString(R.string.admob_interstitial));
}
private void setRewarded() {
// Your Rewar...
Release v4.1.7
About This Project
- Available on Google Dev Library - Click Here
- Helper for activating admob
- Example Source Code For Call Method Show Admob
- Calling method on Inheritance Class
- Implement all Admob Version
- Jetpack Compose Function (Experimental)
Note For Jitpack Build
- Red : Failed (So don't use that version / Using previous version)
- Green : Success / Pass (Use It)
ScreenShot Apps
Banner and Interstitial | RecyclerView with Banner | Rewarded Apps |
---|---|---|
Version Release
$version_release = 4.1.7
What's New??
* Enhance Performance *
* Refactoring Code *
* Update Admob Library Version 20.6.0 *
How To Use / Implement This Project
Step 1. Add the JitPack repository to your build file
<Option 1> Groovy Gradle
// Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
<Option 2> Kotlin DSL Gradle
// Add it in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}
Step 2. Add the dependency
<Option 1> Groovy
dependencies {
// library google ads
implementation 'com.google.android.gms:play-services-ads:${latest_version}'
// library frogo-admob-helper
implementation 'com.github.amirisback:frogo-admob:4.1.7'
}
<Option 2> Kotlin DSL
dependencies {
// library google ads
implementation("com.google.android.gms:play-services-ads:${latest_version}")
// library frogo-admob-helper
implementation("com.github.amirisback:frogo-admob:4.1.7")
}
Step 3. Adding meta-data on AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
Step 4. Setup Admob and Showing Ads
XML
Click for detail!
Setup Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
}
private fun setupAdmob(){
setPublisher()
setBanner()
setInterstitial()
setRewarded()
setRewardedInterstitial()
}
private fun setPublisher() {
setupAdsPublisher(getString(R.string.admob_publisher_id))
}
private fun setBanner() {
setupAdsBanner(getString(R.string.admob_banner))
}
private fun setInterstitial() {
// setupAdsInterstitial(getString(R.string.admob_interstitial))
}
private fun setRewarded() {
setupAdsRewarded(getString(R.string.admob_rewarded))
}
private fun setRewardedInterstitial() {
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial))
}
}
Showing Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
setupButtonClick()
setupBannerAds()
}
...
...
...
private fun setupBannerAds() {
setupShowAdsBannerContainer(
this,
AdSize.SMART_BANNER,
binding.includeAdsView.frogoAdsBanner
)
setupShowAdsBanner(binding.adsXml.adsPhoneTabSpecialSmartBanner)
}
private fun setupButtonClick() {
binding.apply {
btnInterstitial.setOnClickListener {
// setupShowAdsInterstitial()
val listener = object : IFrogoAdListener.Interstitial {
override fun onAdFailedToLoad(adError: LoadAdError) {
showToast("Gagal Iklan")
}
override fun onAdLoaded(interstitialAd: InterstitialAd) {
}
}
FrogoAdmob.Interstitial.setupInterstitial(this@MainActivity, "", listener)
FrogoAdmob.Interstitial.showInterstitial(this@MainActivity, listener)
}
btnRewarded.setOnClickListener {
setupShowAdsRewarded(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
btnRewardedInterstitial.setOnClickListener {
setupShowAdsRewardedInterstitial(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
}
}
}
Jetpack Compose
Click for detail!
ComposeActivity
class ComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
FrogoAdmobTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Column {
FrogoAdmobBannerView(
mAdUnitID = getString(R.string.admob_banner),
mAdSize = adsize_banner
)
}
}
}
}
}
}
Hybrid (Jetpack Compose + XML)
Click for detail!
XML Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mvvm.main.MainActivity">
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/include_ads_view"/>
<include
android:id="@+id/include_ads_view"
layout="@layout/ads_phone_tab_special_smart_banner" />
</RelativeLayout>
Kotlin Class
class HybridActivity : BaseActivity<ActivityHybridBinding>() {
override fun setupViewBinding(): ActivityHybridBinding {
return ActivityHybridBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.apply {
composeView.setContent {
Greeting("FrogoAdmob")
}
setupShowAdsBanner(includeAdsView.adsPhoneTabSpecialSmartBanner)
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
}
Java Sample Implementation
- You can follow sample below or go to Full Sample Code Full Code
Click for detail!
Setup Java BaseActivity
public abstract class <Your BaseJavaActivity> extends FrogoAdmobActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupAdmob();
}
private void setupAdmob(){
setPublisher();
setBanner();
setInterstitial();
setRewarded();
setRewardedInterstitial();
}
private void setPublisher() {
// Your App ID
setupAdsPublisher(getString(R.string.admob_publisher_id));
}
private void setBanner() {
// Your Banner ID
setupAdsBanner(getString(R.string.admob_banner));
}
private void setInterstitial() {
// Your Interstitial ID
setupAdsInterstitial(getString(R.string.admob_interstitial));
}
private void setRewarded() {
// Your Rewarded ID
setupAdsRewarded(getString(R.string.admob_rewarded));
}
private void setRewardedInterstitial() {
// Your Rewarded ID
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial));
}
}
Setup Your Activi...
Release v4.1.6
About This Project
- Available on Google Dev Library - Click Here
- Helper for activating admob
- Example Source Code For Call Method Show Admob
- Calling method on Inheritance Class
- Implement all Admob Version
- Jetpack Compose Function (Experimental)
Note For Jitpack Build
- Red : Failed (So don't use that version / Using previous version)
- Green : Success / Pass (Use It)
ScreenShot Apps
Banner and Interstitial | RecyclerView with Banner | Rewarded Apps |
---|---|---|
Version Release
$version_release = 4.1.6
What's New??
* Enhance Performance *
* Refactoring Code *
* Update Admob Library Version 20.5.0 *
How To Use / Implement This Project
Step 1. Add the JitPack repository to your build file
<Option 1> Groovy Gradle
// Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
<Option 2> Kotlin DSL Gradle
// Add it in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}
Step 2. Add the dependency
<Option 1> Groovy
dependencies {
// library google ads
implementation 'com.google.android.gms:play-services-ads:${latest_version}'
// library frogo-admob-helper
implementation 'com.github.amirisback:frogo-admob:4.1.6'
}
<Option 2> Kotlin DSL
dependencies {
// library google ads
implementation("com.google.android.gms:play-services-ads:${latest_version}")
// library frogo-admob-helper
implementation("com.github.amirisback:frogo-admob:4.1.6")
}
Step 3. Adding meta-data on AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
Step 4. Setup Admob and Showing Ads
XML
Click for detail!
Setup Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
}
private fun setupAdmob(){
setPublisher()
setBanner()
setInterstitial()
setRewarded()
setRewardedInterstitial()
}
private fun setPublisher() {
setupAdsPublisher(getString(R.string.admob_publisher_id))
}
private fun setBanner() {
setupAdsBanner(getString(R.string.admob_banner))
}
private fun setInterstitial() {
setupAdsInterstitial(getString(R.string.admob_interstitial))
}
private fun setRewarded() {
setupAdsRewarded(getString(R.string.admob_rewarded))
}
private fun setRewardedInterstitial() {
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial))
}
}
Showing Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
setupButtonClick()
}
...
...
...
private fun setupButtonClick() {
binding.apply {
btnInterstitial.setOnClickListener {
setupShowAdsInterstitial()
}
btnRewarded.setOnClickListener {
setupShowAdsRewarded(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
btnRewardedInterstitial.setOnClickListener {
setupShowAdsRewardedInterstitial(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
}
}
}
Jetpack Compose
Click for detail!
ComposeActivity
class ComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
FrogoAdmobTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Column {
FrogoAdmobBannerView(
mAdUnitID = getString(R.string.admob_banner),
mAdSize = adsize_banner
)
}
}
}
}
}
}
Hybrid (Jetpack Compose + XML)
Click for detail!
XML Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mvvm.main.MainActivity">
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/include_ads_view"/>
<include
android:id="@+id/include_ads_view"
layout="@layout/ads_phone_tab_special_smart_banner" />
</RelativeLayout>
Kotlin Class
class HybridActivity : BaseActivity<ActivityHybridBinding>() {
override fun setupViewBinding(): ActivityHybridBinding {
return ActivityHybridBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.apply {
composeView.setContent {
Greeting("FrogoAdmob")
}
setupShowAdsBanner(includeAdsView.adsPhoneTabSpecialSmartBanner)
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
}
Java Sample Implementation
- You can follow sample below or go to Full Sample Code Full Code
Click for detail!
Setup Java BaseActivity
public abstract class <Your BaseJavaActivity> extends FrogoAdmobActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupAdmob();
}
private void setupAdmob(){
setPublisher();
setBanner();
setInterstitial();
setRewarded();
setRewardedInterstitial();
}
private void setPublisher() {
// Your App ID
setupAdsPublisher(getString(R.string.admob_publisher_id));
}
private void setBanner() {
// Your Banner ID
setupAdsBanner(getString(R.string.admob_banner));
}
private void setInterstitial() {
// Your Interstitial ID
setupAdsInterstitial(getString(R.string.admob_interstitial));
}
private void setRewarded() {
// Your Rewarded ID
setupAdsRewarded(getString(R.string.admob_rewarded));
}
private void setRewardedInterstitial() {
// Your Rewarded ID
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial));
}
}
Setup Your Activity
public class MainJavaActivity extends BaseJavaActivity {
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(LayoutInflater.from(this));
setContentView(binding.getRoot());
setupShowAdsBanner(binding.includeAdsView.adsPhoneTabSpecialSmartBanner);
hideButton();
setupButtonClick();
}
...
...
...
private void setupButtonClick() {
binding.btnInterstitial.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setupShowAdsInterstitial();
}
});
binding.btnRewarded.setOnC...
Release v4.1.5
About This Project
- Available on Google Dev Library - Click Here
- Helper for activating admob
- Example Source Code For Call Method Show Admob
- Calling method on Inheritance Class
- Implement all Admob Version
- Jetpack Compose Function (Experimental)
Note For Jitpack Build
- Red : Failed (So don't use that version / Using previous version)
- Green : Success / Pass (Use It)
ScreenShot Apps
Banner and Interstitial | RecyclerView with Banner | Rewarded Apps |
---|---|---|
Version Release
$version_release = 4.1.5
What's New??
* Enhance Performance *
* Refactoring Code *
* Update Admob Library Version 20.5.0 *
How To Use / Implement This Project
Step 1. Add the JitPack repository to your build file
<Option 1> Groovy Gradle
// Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
<Option 2> Kotlin DSL Gradle
// Add it in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}
Step 2. Add the dependency
<Option 1> Groovy
dependencies {
// library google ads
implementation 'com.google.android.gms:play-services-ads:${latest_version}'
// library frogo-admob-helper
implementation 'com.github.amirisback:frogo-admob:4.1.5'
}
<Option 2> Kotlin DSL
dependencies {
// library google ads
implementation("com.google.android.gms:play-services-ads:${latest_version}")
// library frogo-admob-helper
implementation("com.github.amirisback:frogo-admob:4.1.5")
}
Step 3. Adding meta-data on AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
Step 4. Setup Admob and Showing Ads
XML
Click for detail!
Setup Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
}
private fun setupAdmob(){
setPublisher()
setBanner()
setInterstitial()
setRewarded()
setRewardedInterstitial()
}
private fun setPublisher() {
setupAdsPublisher(getString(R.string.admob_publisher_id))
}
private fun setBanner() {
setupAdsBanner(getString(R.string.admob_banner))
}
private fun setInterstitial() {
setupAdsInterstitial(getString(R.string.admob_interstitial))
}
private fun setRewarded() {
setupAdsRewarded(getString(R.string.admob_rewarded))
}
private fun setRewardedInterstitial() {
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial))
}
}
Showing Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
setupButtonClick()
}
...
...
...
private fun setupButtonClick() {
binding.apply {
btnInterstitial.setOnClickListener {
setupShowAdsInterstitial()
}
btnRewarded.setOnClickListener {
setupShowAdsRewarded(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
btnRewardedInterstitial.setOnClickListener {
setupShowAdsRewardedInterstitial(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
}
}
}
Jetpack Compose
Click for detail!
ComposeActivity
class ComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
FrogoAdmobTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Column {
FrogoAdmobBannerView(
mAdUnitID = getString(R.string.admob_banner),
mAdSize = adsize_banner
)
}
}
}
}
}
}
Hybrid (Jetpack Compose + XML)
Click for detail!
XML Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mvvm.main.MainActivity">
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/include_ads_view"/>
<include
android:id="@+id/include_ads_view"
layout="@layout/ads_phone_tab_special_smart_banner" />
</RelativeLayout>
Kotlin Class
class HybridActivity : BaseActivity<ActivityHybridBinding>() {
override fun setupViewBinding(): ActivityHybridBinding {
return ActivityHybridBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.apply {
composeView.setContent {
Greeting("FrogoAdmob")
}
setupShowAdsBanner(includeAdsView.adsPhoneTabSpecialSmartBanner)
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
}
Java Sample Implementation
- You can follow sample below or go to Full Sample Code Full Code
Click for detail!
Setup Java BaseActivity
public abstract class <Your BaseJavaActivity> extends FrogoAdmobActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupAdmob();
}
private void setupAdmob(){
setPublisher();
setBanner();
setInterstitial();
setRewarded();
setRewardedInterstitial();
}
private void setPublisher() {
// Your App ID
setupAdsPublisher(getString(R.string.admob_publisher_id));
}
private void setBanner() {
// Your Banner ID
setupAdsBanner(getString(R.string.admob_banner));
}
private void setInterstitial() {
// Your Interstitial ID
setupAdsInterstitial(getString(R.string.admob_interstitial));
}
private void setRewarded() {
// Your Rewarded ID
setupAdsRewarded(getString(R.string.admob_rewarded));
}
private void setRewardedInterstitial() {
// Your Rewarded ID
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial));
}
}
Setup Your Activity
public class MainJavaActivity extends BaseJavaActivity {
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(LayoutInflater.from(this));
setContentView(binding.getRoot());
setupShowAdsBanner(binding.includeAdsView.adsPhoneTabSpecialSmartBanner);
hideButton();
setupButtonClick();
}
...
...
...
private void setupButtonClick() {
binding.btnInterstitial.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setupShowAdsInterstitial();
}
});
binding.btnRewarded.setOnC...
Release v4.1.4
About This Project
- Available on Google Dev Library - Click Here
- Helper for activating admob
- Example Source Code For Call Method Show Admob
- Calling method on Inheritance Class
- Implement all Admob Version
- Jetpack Compose Function (Experimental)
Note For Jitpack Build
- Red : Failed (So don't use that version / Using previous version)
- Green : Success / Pass (Use It)
ScreenShot Apps
Banner and Interstitial | RecyclerView with Banner | Rewarded Apps |
---|---|---|
Version Release
$version_release = 4.1.4
What's New??
* Enhance Performance *
* Refactoring Code *
* Remove unused code *
* Update documentation *
* Update build.gradle *
* Update sample code *
* Update Android Gradle Plugin 7.0.2 *
* Update Admob Library Version 20.5.0 *
* Add Compose Implementation (Experimental) *
* Add Java Sample *
How To Use / Implement This Project
Step 1. Add the JitPack repository to your build file
<Option 1> Groovy Gradle
// Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
<Option 2> Kotlin DSL Gradle
// Add it in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}
Step 2. Add the dependency
<Option 1> Groovy
dependencies {
// library google ads
implementation 'com.google.android.gms:play-services-ads:${latest_version}'
// library frogo-admob-helper
implementation 'com.github.amirisback:frogo-admob:4.1.4'
}
<Option 2> Kotlin DSL
dependencies {
// library google ads
implementation("com.google.android.gms:play-services-ads:${latest_version}")
// library frogo-admob-helper
implementation("com.github.amirisback:frogo-admob:4.1.4")
}
Step 3. Adding meta-data on AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
Step 4. Setup Admob and Showing Ads
XML
Click for detail!
Setup Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
}
private fun setupAdmob(){
setPublisher()
setBanner()
setInterstitial()
setRewarded()
setRewardedInterstitial()
}
private fun setPublisher() {
setupAdsPublisher(getString(R.string.admob_publisher_id))
}
private fun setBanner() {
setupAdsBanner(getString(R.string.admob_banner))
}
private fun setInterstitial() {
setupAdsInterstitial(getString(R.string.admob_interstitial))
}
private fun setRewarded() {
setupAdsRewarded(getString(R.string.admob_rewarded))
}
private fun setRewardedInterstitial() {
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial))
}
}
Showing Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
setupButtonClick()
}
...
...
...
private fun setupButtonClick() {
binding.apply {
btnInterstitial.setOnClickListener {
setupShowAdsInterstitial()
}
btnRewarded.setOnClickListener {
setupShowAdsRewarded(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
btnRewardedInterstitial.setOnClickListener {
setupShowAdsRewardedInterstitial(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
}
}
}
Jetpack Compose
Click for detail!
ComposeActivity
class ComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
FrogoAdmobTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Column {
FrogoAdmobBannerView(
mAdUnitID = getString(R.string.admob_banner),
mAdSize = adsize_banner
)
}
}
}
}
}
}
Hybrid (Jetpack Compose + XML)
Click for detail!
XML Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mvvm.main.MainActivity">
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/include_ads_view"/>
<include
android:id="@+id/include_ads_view"
layout="@layout/ads_phone_tab_special_smart_banner" />
</RelativeLayout>
Kotlin Class
class HybridActivity : BaseActivity<ActivityHybridBinding>() {
override fun setupViewBinding(): ActivityHybridBinding {
return ActivityHybridBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.apply {
composeView.setContent {
Greeting("FrogoAdmob")
}
setupShowAdsBanner(includeAdsView.adsPhoneTabSpecialSmartBanner)
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
}
Java Sample Implementation
- You can follow sample below or go to Full Sample Code Full Code
Click for detail!
Setup Java BaseActivity
public abstract class <Your BaseJavaActivity> extends FrogoAdmobActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupAdmob();
}
private void setupAdmob(){
setPublisher();
setBanner();
setInterstitial();
setRewarded();
setRewardedInterstitial();
}
private void setPublisher() {
// Your App ID
setupAdsPublisher(getString(R.string.admob_publisher_id));
}
private void setBanner() {
// Your Banner ID
setupAdsBanner(getString(R.string.admob_banner));
}
private void setInterstitial() {
// Your Interstitial ID
setupAdsInterstitial(getString(R.string.admob_interstitial));
}
private void setRewarded() {
// Your Rewarded ID
setupAdsRewarded(getString(R.string.admob_rewarded));
}
private void setRewardedInterstitial() {
// Your Rewarded ID
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial));
}
}
Setup Your Activity
public class MainJavaActivity extends BaseJavaActivity {
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(LayoutInflater.from(this));
setContentView(binding.getRoot());
setupShowAdsBanner(binding.includeAdsView.adsPhoneTabSpecialSmartBanner);
hideButton();
setupButtonClick();
}
...
...
...
private void setupButtonClick() {
binding.btnInter...
Release v4.1.3
Version Release
$version_release = 4.1.3
What's New??
* Enhance Performance *
* Refactoring Code *
* Remove unused code *
* Update documentation *
* Update build.gradle *
* Update sample code *
* Update Android Gradle Plugin 7.0.2 *
* Update Admob Library Version 20.4.0 *
* Add Compose Implementation (Experimental) *
How To Use / Implement This Project
Step 1. Add the JitPack repository to your build file
<Option 1> Groovy Gradle
// Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
<Option 2> Kotlin DSL Gradle
// Add it in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}
Step 2. Add the dependency
<Option 1> Groovy
dependencies {
// library google ads
implementation 'com.google.android.gms:play-services-ads:${latest_version}'
// library frogo-admob-helper
implementation 'com.github.amirisback:frogo-admob:4.1.3'
}
<Option 2> Kotlin DSL
dependencies {
// library google ads
implementation("com.google.android.gms:play-services-ads:${latest_version}")
// library frogo-admob-helper
implementation("com.github.amirisback:frogo-admob:4.1.3")
}
Step 3. Adding meta-data on AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
Step 4. Setup Admob and Showing Ads
XML
Click for detail!
Setup Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
}
private fun setupAdmob(){
setPublisher()
setBanner()
setInterstitial()
setRewarded()
setRewardedInterstitial()
}
private fun setPublisher() {
setupAdsPublisher(getString(R.string.admob_publisher_id))
}
private fun setBanner() {
setupAdsBanner(getString(R.string.admob_banner))
}
private fun setInterstitial() {
setupAdsInterstitial(getString(R.string.admob_interstitial))
}
private fun setRewarded() {
setupAdsRewarded(getString(R.string.admob_rewarded))
}
private fun setRewardedInterstitial() {
setupAdsRewardedInterstitial(getString(R.string.admob_rewarded_interstitial))
}
}
Showing Ads
class <YourActivity> : FrogoAdmobActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupAdmob()
setupButtonClick()
}
...
...
...
private fun setupButtonClick() {
binding.apply {
btnInterstitial.setOnClickListener {
setupShowAdsInterstitial()
}
btnRewarded.setOnClickListener {
setupShowAdsRewarded(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
btnRewardedInterstitial.setOnClickListener {
setupShowAdsRewardedInterstitial(object : IFrogoAdmob.UserEarned {
override fun onUserEarnedReward(rewardItem: RewardItem) {
// TODO User Get Reward
}
})
}
}
}
}
Jetpack Compose
Click for detail!
ComposeActivity
class ComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
FrogoAdmobTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Column {
FrogoAdmobBannerView(
mAdUnitID = getString(R.string.admob_banner),
mAdSize = adsize_banner
)
}
}
}
}
}
}
Hybrid (Jetpack Compose + XML)
Click for detail!
XML Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mvvm.main.MainActivity">
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/include_ads_view"/>
<include
android:id="@+id/include_ads_view"
layout="@layout/ads_phone_tab_special_smart_banner" />
</RelativeLayout>
Kotlin Class
class HybridActivity : BaseActivity<ActivityHybridBinding>() {
override fun setupViewBinding(): ActivityHybridBinding {
return ActivityHybridBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.apply {
composeView.setContent {
Greeting("FrogoAdmob")
}
setupShowAdsBanner(includeAdsView.adsPhoneTabSpecialSmartBanner)
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
}
Jetpack Compose Element
Variable
val adsize_banner: AdSize = AdSize.BANNER
val adsize_full_banner: AdSize = AdSize.FULL_BANNER
val adsize_large_banner: AdSize = AdSize.LARGE_BANNER
val adsize_smart_banner: AdSize = AdSize.SMART_BANNER
val adsize_medium_rectangle: AdSize = AdSize.MEDIUM_RECTANGLE
val adsize_wide_skycraper: AdSize = AdSize.WIDE_SKYSCRAPER
Function
@Composable
fun FrogoAdmobBannerView(
mAdUnitID: String,
mAdSize: AdSize,
modifier: Modifier = Modifier
) {
AndroidView(
modifier = modifier.fillMaxWidth(),
factory = { context ->
FLog.d("FrogoAdmobBannerView")
AdView(context).apply {
adSize = mAdSize
adUnitId = mAdUnitID
loadAd(AdRequest.Builder().build())
}
}
)
}
Release v4.1.2
* Enhance Performance *
* Refactoring Code *
* Remove unused code *
* Update documentation *
* Update build.gradle *
* Update sample code *
* Update Android Gradle Plugin 7.0.1 *
* Update Admob Library Version 20.3.0 *
Release v4.1.1
* Enhance Performance *
* Refactoring Code *
* Remove unused code *
* Update documentation *
* Update build.gradle *
* Update sample code *
* Update Android Gradle Plugin 7.0.1 *
Release v4.0.6
* Enhance Performance *
* Refactoring Code *
* Remove unused code *
* Update documentation *
* Update build.gradle *
* Update sample code *
Release v4.0.1
* Enhance Performance *
* Refactoring Code *
* Remove unused code *
* Update documentation *
* Update build.gradle *
* Update sample code *