Disable ads in debug build

This commit is contained in:
Attila Uygun 2023-05-21 22:05:49 +02:00
parent c90d039944
commit 0454bf6a18
1 changed files with 17 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package com.kaliber.base;
import android.app.NativeActivity; import android.app.NativeActivity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -37,19 +38,26 @@ public class KaliberActivity extends NativeActivity {
private InterstitialAd mInterstitialAd; private InterstitialAd mInterstitialAd;
boolean mIsDebuggable = false;
public static native void onShowAdResult(boolean succeeded); public static native void onShowAdResult(boolean succeeded);
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
MobileAds.initialize(this, new OnInitializationCompleteListener() { ApplicationInfo appInfo = getApplicationContext().getApplicationInfo();
@Override mIsDebuggable = (appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
public void onInitializationComplete(InitializationStatus initializationStatus) {
Log.d("kaliber", "MobileAds initialization complete."); if (!mIsDebuggable) {
} MobileAds.initialize(this, new OnInitializationCompleteListener() {
}); @Override
loadInterstitialAd(); public void onInitializationComplete(InitializationStatus initializationStatus) {
Log.d("kaliber", "MobileAds initialization complete.");
}
});
loadInterstitialAd();
}
} }
public void setKeepScreenOn(final boolean keepScreenOn) { public void setKeepScreenOn(final boolean keepScreenOn) {
@ -66,6 +74,8 @@ public class KaliberActivity extends NativeActivity {
} }
public void showInterstitialAd() { public void showInterstitialAd() {
if (mIsDebuggable) return;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {