文档

配置启动页

更新时间:

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

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

说明

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

基于 mPaaS 框架下,启动页的时序和原理如下:

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

  2. 首页中检查并打开启动页。

使用示例

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

         @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         // 首页逻辑
         // ........
         // ........
         // ........
         if (SplashActivity.checkIfSplashPrepared()) {
             startSplash();
         }
     }
    
     private void startSplash() {
         startActivity(new Intent(this, SplashActivity.class));
         overridePendingTransition(0, 0); // 去掉转场动画
     }
  2. 在启动页 SplashActivity 中展示开屏。

     private void doSplash() {
         final CdpAdvertisementService cdpAdvertisementService = cpdService();
         cdpAdvertisementService.doSplash(this, new HashMap<String, String>(), new CdpAdvertisementService.IAdEventHandler() {
             @Override
              public void onClosed(SpaceInfo spaceInfo) {
             }
    
             @Override
             public void onJump(SpaceInfo spaceInfo) {
                 // 跳转到活动目标页面
             }
         });
     }
    
     public static CdpAdvertisementService cpdService() {
         CdpAdvertisementService serviceByInterface = LauncherApplicationAgent.getInstance().getMicroApplicationContext().findServiceByInterface(
             CdpAdvertisementService.class.getName());
         return serviceByInterface;
     }
  • 本页导读 (0)
文档反馈