移动开发平台 mPaaS 配置启动页

By | 2021年4月23日

启动页广告又称开屏广告。启动页(也称为闪屏/开屏 Splash)是在应用启动之后,框架初始化完成时展示,应用首页出现时消失。

在客户端配置启动页后,您可以在控制台侧配置 Splash 展位信息与广告内容(参见 创建展位创建营销活动)。启动页开屏展位的疲劳度控制最好配置为“展示 xx 秒之后消失”,应用根据配置获取展位投放数据并进行展示,并在倒计时 xx 秒之后关闭页面,实现了投放数据的动态下发与展示。

说明:由于投放数据的下载是异步过程,为了不阻塞应用的启动,配置启动页的投放后,首次仅执行下载操作,将图片缓存到本地,下一次应用启动时才会展示上一次缓存的图片。

基于 mPaaS 框架(关于 mPaaS 框架的详细介绍,参见 mPaaS 框架介绍)下,启动页的时序和原理如下:

  1. 框架启动后主线程创建并初始化 LauncherActivityAgent,在 LauncherActivityAgent.postInit 的回调方法中打开首页。
  2. 首页中检查并打开启动页。

使用示例

  1. 在首页中初始化启动页。

        
    1. @Override
    2. protected void onCreate(Bundle savedInstanceState) {
    3. super.onCreate(savedInstanceState);
    4. // 首页逻辑
    5. // ........
    6. // ........
    7. // ........
    8. if (SplashActivity.checkIfSplashPrepared()) {
    9. startSplash();
    10. }
    11. }
    12. private void startSplash() {
    13. startActivity(new Intent(this, SplashActivity.class));
    14. overridePendingTransition(0, 0); // 去掉转场动画
    15. }
  2. 在启动页 SplashActivity 中展示开屏。

        
    1. private void doSplash() {
    2. final CdpAdvertisementService cdpAdvertisementService = cpdService();
    3. cdpAdvertisementService.doSplash(this, new HashMap<String, String>(), new CdpAdvertisementService.IAdEventHandler() {
    4. @Override
    5. public void onClosed(SpaceInfo spaceInfo) {
    6. }
    7. @Override
    8. public void onJump(SpaceInfo spaceInfo) {
    9. // 跳转到活动目标页面
    10. }
    11. });
    12. }
    13. public static CdpAdvertisementService cpdService() {
    14. CdpAdvertisementService serviceByInterface = LauncherApplicationAgent.getInstance().getMicroApplicationContext().findServiceByInterface(
    15. CdpAdvertisementService.class.getName());
    16. return serviceByInterface;
    17. }

请关注公众号获取更多资料

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注