更新米盟 SDK 广告显示方案
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Nov 18 16:40:26 HKT 2025
|
||||
#Wed Nov 19 00:33:17 GMT 2025
|
||||
stageCount=2
|
||||
libraryProject=libaes
|
||||
baseVersion=15.11
|
||||
publishVersion=15.11.1
|
||||
buildCount=0
|
||||
buildCount=13
|
||||
baseBetaVersion=15.11.2
|
||||
|
||||
19
build.gradle
19
build.gradle
@@ -5,6 +5,16 @@ buildscript {
|
||||
// 设置本地Maven仓库路径
|
||||
url 'file:///sdcard/.m2/repository/'
|
||||
}
|
||||
|
||||
//米盟通过maven接入时,要做如下配置
|
||||
maven {
|
||||
url "https://repos.xiaomi.com/maven"
|
||||
credentials {
|
||||
username 'mimo-developer'
|
||||
password 'AKCp8ih1PFG9tV8qaLyws67dLGZi8udFM39SfsHgihN15cgsiRvHuxj8JzFmuZjaViVeNawaA'
|
||||
}
|
||||
}
|
||||
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoLL Release"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
@@ -40,6 +50,15 @@ allprojects {
|
||||
// 设置本地Maven仓库路径
|
||||
url 'file:///sdcard/.m2/repository/'
|
||||
}
|
||||
|
||||
//米盟通过maven接入时,要做如下配置
|
||||
maven {
|
||||
url "https://repos.xiaomi.com/maven"
|
||||
credentials {
|
||||
username 'mimo-developer'
|
||||
password 'AKCp8ih1PFG9tV8qaLyws67dLGZi8udFM39SfsHgihN15cgsiRvHuxj8JzFmuZjaViVeNawaA'
|
||||
}
|
||||
}
|
||||
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoLL Release"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Nov 18 16:40:13 HKT 2025
|
||||
#Wed Nov 19 00:33:17 GMT 2025
|
||||
stageCount=2
|
||||
libraryProject=libaes
|
||||
baseVersion=15.11
|
||||
publishVersion=15.11.1
|
||||
buildCount=0
|
||||
buildCount=13
|
||||
baseBetaVersion=15.11.2
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="cc.winboll.studio.libaes">
|
||||
|
||||
<application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
|
||||
<!-- 通过GPS得到精确位置 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- 通过网络得到粗略位置 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
|
||||
<activity
|
||||
android:name="cc.winboll.studio.libaes.unittests.SecondaryLibraryActivity"
|
||||
@@ -33,6 +49,18 @@
|
||||
android:name="cc.winboll.studio.libaes.winboll.WinBoLLMail"
|
||||
android:exported="true"/>
|
||||
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package cc.winboll.studio.libaes.views;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
@@ -18,10 +20,12 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import cc.winboll.studio.libaes.R;
|
||||
import cc.winboll.studio.libaes.utils.MimoUtils;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import com.miui.zeus.mimo.sdk.ADParams;
|
||||
import com.miui.zeus.mimo.sdk.BannerAd;
|
||||
import com.miui.zeus.mimo.sdk.MimoCustomController;
|
||||
@@ -30,7 +34,6 @@ import com.miui.zeus.mimo.sdk.MimoSdk;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
@@ -47,13 +50,13 @@ public class ADsBannerView extends LinearLayout {
|
||||
private String BANNER_POS_ID = "802e356f1726f9ff39c69308bfd6f06a";
|
||||
private String BANNER_POS_ID_WINBOLL_BETA = "d129ee5a263911f981a6dc7a9802e3e7";
|
||||
private String BANNER_POS_ID_WINBOLL = "4ec30efdb32271765b9a4efac902828b";
|
||||
|
||||
|
||||
/*
|
||||
private String BANNER_POS_ID = "802e356f1726f9ff39c69308bfd6f06a";
|
||||
private String BANNER_POS_ID_WINBOLL_BETA = "802e356f1726f9ff39c69308bfd6f06a";
|
||||
private String BANNER_POS_ID_WINBOLL = "802e356f1726f9ff39c69308bfd6f06a";
|
||||
*/
|
||||
|
||||
private String BANNER_POS_ID = "802e356f1726f9ff39c69308bfd6f06a";
|
||||
private String BANNER_POS_ID_WINBOLL_BETA = "802e356f1726f9ff39c69308bfd6f06a";
|
||||
private String BANNER_POS_ID_WINBOLL = "802e356f1726f9ff39c69308bfd6f06a";
|
||||
*/
|
||||
|
||||
Context mContext;
|
||||
View mMianView;
|
||||
SharedPreferences mSharedPreferences;
|
||||
@@ -88,7 +91,7 @@ public class ADsBannerView extends LinearLayout {
|
||||
}
|
||||
|
||||
void initView() {
|
||||
|
||||
|
||||
// 初始化主线程Handler(关键:确保广告操作在主线程执行)
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@@ -110,9 +113,8 @@ public class ADsBannerView extends LinearLayout {
|
||||
}
|
||||
|
||||
public void resumeADs() {
|
||||
//ToastUtils.show("resumeADs()");
|
||||
// 修复:优化广告请求逻辑(添加生命周期判断 + 主线程执行)
|
||||
if (getActivity() != null && !getActivity().isFinishing() && !getActivity().isDestroyed()) {
|
||||
// 修复:优化广告请求逻辑(添加生命周期判断 + 主线程执行)
|
||||
if (getActivity() != null && !getActivity().isFinishing() && !getActivity().isDestroyed()) {
|
||||
String privacyAgreeValue = getSharedPreferences().getString(PRIVACY_VALUE, null);
|
||||
if (TextUtils.equals(privacyAgreeValue, String.valueOf(1))) {
|
||||
LogUtils.i(TAG, "已同意隐私协议,开始播放米盟广告...");
|
||||
@@ -127,9 +129,8 @@ public class ADsBannerView extends LinearLayout {
|
||||
}
|
||||
}, 1000); // 延迟1秒请求广告,提升页面加载体验
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放广告资源(关键:避免内存泄漏和空Context调用)
|
||||
@@ -258,7 +259,9 @@ public class ADsBannerView extends LinearLayout {
|
||||
|
||||
@Override
|
||||
public void onDownloadFailed(int errorCode) {
|
||||
LogUtils.d(TAG, "onDownloadFailed, errorCode = " + errorCode);
|
||||
String msg = "onDownloadFailed, errorCode = " + errorCode;
|
||||
LogUtils.d(TAG, msg);
|
||||
//ToastUtils.show(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -308,17 +311,26 @@ public class ADsBannerView extends LinearLayout {
|
||||
|
||||
@Override
|
||||
public void onAdLoadFailed(int errorCode, String errorMsg) {
|
||||
LogUtils.e(TAG, "onAdLoadFailed: errorCode = " + errorCode + ", errorMsg = " + errorMsg);
|
||||
// 修复:加载失败时移除当前广告实例
|
||||
if (mAllBanners.contains(mBannerAd)) {
|
||||
mAllBanners.remove(mBannerAd);
|
||||
String msg = "onAdLoadFailed: errorCode = " + errorCode + ", errorMsg = " + errorMsg;
|
||||
LogUtils.d(TAG, msg);
|
||||
if (errorCode == 300219) {
|
||||
// 如果是广告拉取错误就提示一下
|
||||
ToastUtils.show(String.format("米盟 SDK Error Code : %d", errorCode));
|
||||
}
|
||||
mBannerAd.destroy();
|
||||
mBannerAd = null;
|
||||
removeAllBanners();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void removeAllBanners() {
|
||||
// 修复:加载失败时移除当前广告实例
|
||||
if (mAllBanners.contains(mBannerAd)) {
|
||||
mAllBanners.remove(mBannerAd);
|
||||
}
|
||||
mBannerAd.destroy();
|
||||
mBannerAd = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前秒数获取广告ID(原逻辑保留)
|
||||
*/
|
||||
|
||||
5
libaes/src/main/res/xml/file_paths.xml
Normal file
5
libaes/src/main/res/xml/file_paths.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<external-path path="mimoDownload" name="files_root" />
|
||||
<external-path path="." name="external_storage_root" />
|
||||
</paths>
|
||||
@@ -4,4 +4,13 @@
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="true">winboll.cc</domain>
|
||||
</domain-config>
|
||||
<!-- 米盟 SDK 配置 -->
|
||||
<base-config cleartextTrafficPermitted="true" />
|
||||
<debug-overrides>
|
||||
<trust-anchors>
|
||||
<!-- Trust user added CAs while debuggable only -->
|
||||
<certificates src="system" />
|
||||
<certificates src="user" />
|
||||
</trust-anchors>
|
||||
</debug-overrides>
|
||||
</network-security-config>
|
||||
|
||||
Reference in New Issue
Block a user