DevEco Studio和系统升级后,EntryAbility.ets文件创建悬浮窗失败?

在DevEco Studio和系统升级前,在EntryAbility.ets文件可以创建悬浮窗,升级到最新的之后创建失败。
代码如下:


let floatWindowClass: window.Window | null = null; 
// 1.创建悬浮窗 
const config: window.Configuration = { 
  name: "floatWindow", windowType: window.WindowType.TYPE_FLOAT, ctx: this.context 
}; 
window.createWindow(config, (err: BusinessError, data) => { 
  let errCode: number = err.code; 
  if (errCode) { 
    console.error('floatWindowClass Failed to create the floatWindow. Cause: ' + JSON.stringify(err)); 
    return; 
  } 
  console.info('floatWindowClass Succeeded in creating the floatWindow. Data: ' + JSON.stringify(data)); 
  { 
    let errCode: number = err.code; 
    if (errCode) { 
      console.error('floatWindowClass Failed to create the floatWindow. Cause: ' + JSON.stringify(err)); 
      return; 
    } 
    console.info('floatWindowClass Succeeded in creating the floatWindow. Data: ' + JSON.stringify(data)); 
    floatWindowClass = data; 
    AppStorage.setOrCreate('floatWindowClass', floatWindowClass); 
    // 2.悬浮窗窗口创建成功后,设置悬浮窗的位置、大小及相关属性等。 
    floatWindowClass.moveWindowTo(0, 604, (err: BusinessError) => { 
      let errCode: number = err.code; 
      if (errCode) { 
        console.error('floatWindowClass Failed to move the window. Cause:' + JSON.stringify(err)); 
        return; 
      } 
      console.info('floatWindowClass Succeeded in moving the window.'); 
    }); 
    // 3.为悬浮窗加载对应的目标页面。 
    floatWindowClass.setUIContent("pages/view/AudioComponent", (err: BusinessError) => { 
      let errCode: number = err.code; 
      if (errCode) { 
        console.error('floatWindowClass Failed to load the content. Cause:' + JSON.stringify(err)); 
        return; 
      } 
      console.info('floatWindowClass Succeeded in loading the content.'); 
    }); 
 
    floatWindowClass.on('windowEvent', (data) => { 
      EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_TYPE, data) 
    }); 
  })
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
harmonyos-next
2024-11-29 15:47:22
浏览
收藏 0
回答 0
相关问题
系统升级HarmonyOS系统app签名问题
1407浏览 • 1回复 待解决
HarmonyOS 手机系统升级ui变得卡顿
727浏览 • 1回复 待解决
DevEco Studio 升级的一些问题
10673浏览 • 1回复 待解决
DevEco studio登录失败
756浏览 • 1回复 待解决
使用悬浮端内want唤醒APP
1449浏览 • 1回复 待解决
关于鸿蒙系统升级正式版都有啥机形
10022浏览 • 1回复 待解决
HarmonyOS 横向悬浮
508浏览 • 1回复 待解决
deveco studio中如何升级API10?
3500浏览 • 1回复 已解决
HarmonyOS 是否支持悬浮能力
610浏览 • 1回复 待解决
使用DevEco Studio登录模拟器失败
11848浏览 • 1回复 待解决