AdMob 25.5.0 + UMP 4.0: consentimiento EEA, init en background, proguard mínimo
This commit is contained in:
1 parent
f766e91ec2
commit
6f7bfaff9c
4 files changed
+40
-46
No files matched your search
Vendored
+7
-37
@@ -1,39 +1,9 @@
|
|||||||
# Add project specific ProGuard rules here.
|
# Reglas de keep para anuncios y UMP ya vienen empaquetadas en las propias libs.
|
||||||
# By default, the flags in this file are appended to flags specified
|
# Aquí solo reglas específicas del proyecto.
|
||||||
# in /mnt/kevinmem/Android/sdkLinux/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
|
||||||
# directive in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
# robotocalendarview (jitpack, sin reglas empaquetadas): conservar la vista y su listener
|
||||||
|
-keep class com.marcohc.robotocalendar.** { *; }
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
# Crash legibles si hace falta debug
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
-keepattributes SourceFile,LineNumberTable
|
||||||
# class:
|
-renamesourcefileattribute SourceFile
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
||||||
|
|
||||||
-keepattributes *Annotation*
|
|
||||||
-keepclassmembers class com.google.**.R$* {
|
|
||||||
public static <fields>;
|
|
||||||
}
|
|
||||||
-keep public class com.google.ads.** {*;}
|
|
||||||
-keep public class com.google.android.gms.** {*;}
|
|
||||||
-keep public class com.tappx.** { *; }
|
|
||||||
|
|
||||||
-ignorewarnings
|
|
||||||
|
|
||||||
-keep class * {
|
|
||||||
public private *;
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,10 @@ import java.util.Calendar;
|
|||||||
import com.google.android.gms.ads.AdRequest;
|
import com.google.android.gms.ads.AdRequest;
|
||||||
import com.google.android.gms.ads.AdView;
|
import com.google.android.gms.ads.AdView;
|
||||||
import com.google.android.gms.ads.MobileAds;
|
import com.google.android.gms.ads.MobileAds;
|
||||||
|
import com.google.android.ump.ConsentInformation;
|
||||||
|
import com.google.android.ump.ConsentRequestParameters;
|
||||||
|
import com.google.android.ump.FormError;
|
||||||
|
import com.google.android.ump.UserMessagingPlatform;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -104,11 +108,8 @@ public class MainActivity extends AppCompatActivity implements RobotoCalendarLis
|
|||||||
robotoCalendarView.setShortWeekDays(false);
|
robotoCalendarView.setShortWeekDays(false);
|
||||||
robotoCalendarView.showDateTitle(true);
|
robotoCalendarView.showDateTitle(true);
|
||||||
|
|
||||||
/* Admob ads */
|
/* Admob ads: consentimiento UMP primero, luego init en background y banner */
|
||||||
MobileAds.initialize(getApplicationContext());
|
setUpConsentAndAds();
|
||||||
AdView mAdView = (AdView) findViewById(R.id.adView);
|
|
||||||
AdRequest adRequest = new AdRequest.Builder().build();
|
|
||||||
mAdView.loadAd(adRequest); //request a new ad
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -116,6 +117,31 @@ public class MainActivity extends AppCompatActivity implements RobotoCalendarLis
|
|||||||
registerForContextMenu(txtfraseText);
|
registerForContextMenu(txtfraseText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Consentimiento UMP (obligatorio EEA) y tras él, init de AdMob + banner */
|
||||||
|
private void setUpConsentAndAds() {
|
||||||
|
ConsentRequestParameters params = new ConsentRequestParameters.Builder().build();
|
||||||
|
ConsentInformation consentInfo = UserMessagingPlatform.getConsentInformation(this);
|
||||||
|
consentInfo.requestConsentInfoUpdate(
|
||||||
|
this,
|
||||||
|
params,
|
||||||
|
() -> UserMessagingPlatform.loadAndShowConsentFormIfRequired(
|
||||||
|
this,
|
||||||
|
formError -> initAdsAfterConsent()),
|
||||||
|
formError -> initAdsAfterConsent());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAdsAfterConsent() {
|
||||||
|
/* MobileAds.initialize en background: no bloquee el arranque */
|
||||||
|
new Thread(() -> {
|
||||||
|
MobileAds.initialize(getApplicationContext());
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
AdView mAdView = findViewById(R.id.adView);
|
||||||
|
AdRequest adRequest = new AdRequest.Builder().build();
|
||||||
|
mAdView.loadAd(adRequest);
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume(){
|
public void onResume(){
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
#Tue Oct 20 12:47:34 UTC 2026
|
#Tue Oct 20 12:49:20 UTC 2026
|
||||||
VERSION_CODE=364
|
VERSION_CODE=367
|
||||||
@@ -5,7 +5,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
|||||||
|
|
||||||
# AndroidX
|
# AndroidX
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
# R fields deben ser final: el código Java usa switch(view.getId())/menu items
|
|
||||||
android.nonFinalResIds=false
|
|
||||||
# Necesario mientras se use robotocalendarview (lib pre-AndroidX, se jetifica en build)
|
# Necesario mientras se use robotocalendarview (lib pre-AndroidX, se jetifica en build)
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
Reference in new issue
Block a user