添加AES项目的米盟模块控件。
This commit is contained in:
@@ -47,6 +47,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cc.winboll.studio.powerbell.activities.WinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.views.ADsBannerView;
|
||||
|
||||
/**
|
||||
* 主活动类(修复小米广告SDK空Context崩溃问题)
|
||||
@@ -85,7 +86,8 @@ public class MainActivity extends WinBoLLActivity {
|
||||
private MainViewFragment mMainViewFragment;
|
||||
private Toolbar mToolbar;
|
||||
// 新增:主线程Handler,确保广告操作在主线程执行
|
||||
private Handler mMainHandler;
|
||||
//private Handler mMainHandler;
|
||||
ADsBannerView mADsBannerView;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
@@ -102,6 +104,8 @@ public class MainActivity extends WinBoLLActivity {
|
||||
LogUtils.d(TAG, "onCreate(...)");
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
mADsBannerView = findViewById(R.id.adsbanner);
|
||||
|
||||
// mContainer = findViewById(R.id.ads_container);
|
||||
//
|
||||
// // 初始化主线程Handler(关键:确保广告操作在主线程执行)
|
||||
@@ -139,6 +143,9 @@ public class MainActivity extends WinBoLLActivity {
|
||||
// if (mMainHandler != null) {
|
||||
// mMainHandler.removeCallbacksAndMessages(null);
|
||||
// }
|
||||
if(mADsBannerView != null) {
|
||||
mADsBannerView.releaseAdResources();
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
@@ -211,6 +218,9 @@ public class MainActivity extends WinBoLLActivity {
|
||||
super.onResume();
|
||||
reloadBackground();
|
||||
setBackgroundColor();
|
||||
if(mADsBannerView != null) {
|
||||
mADsBannerView.resumeADs();
|
||||
}
|
||||
|
||||
// // 修复:优化广告请求逻辑(添加生命周期判断 + 主线程执行)
|
||||
// if (!isFinishing() && !isDestroyed()) {
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<cc.winboll.studio.libaes.views.ADsBannerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ADs"/>
|
||||
android:id="@+id/adsbanner"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user