HarmonyOS 让app回到后台(桌面)的系统方法

HarmonyOS 让app回到后台(桌面)的系统方法。


HarmonyOS
2024-11-21 11:45:44
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
FengTianYa
import window from '@ohos.window' 
import { BusinessError } from '@ohos.base'; 
@Entry 
@Component 
struct Page240605161307072 { 
  @State message: string = 'Hello World'; 
  onBackPress() { 
    const context = getContext(this) 
    window.getLastWindow(getContext()).then((data) => { 
      //获取窗口对象 
      let windowClass = data; 
      windowClass.minimize((err: BusinessError) => { 
        const errCode: number = err.code; 
        if (errCode) { 
          console.error('Failed to minimize the window. Cause: ' + JSON.stringify(err)); 
          return; 
        } 
        console.info('Succeeded in minimizing the window.'); 
      }); 
      console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); 
    }); 
    return true; 
  } 
  build() { 
    Row() { 
      Column() { 
        Text(this.message) 
          .fontSize(50) 
          .fontWeight(FontWeight.Bold) 
        TextInput() 
      } 
      .width('100%') 
    } 
    .height('100%') 
  } 
}
分享
微博
QQ
微信
回复
2024-11-21 15:42:14
相关问题
HarmonyOS 回到桌面API咨询
207浏览 • 1回复 待解决
鸿蒙系统能否禁止app常驻后台
15933浏览 • 1回复 待解决
TextInput在聚焦时如何光标回到起点
2531浏览 • 3回复 待解决
HarmonyOS 如何返回系统桌面
167浏览 • 1回复 待解决
HarmonyOS 如何应用后台运行
1247浏览 • 1回复 待解决
HarmonyOS app创建桌面快捷方式接口
304浏览 • 1回复 待解决
HarmonyOS 不关闭app直接退到桌面
137浏览 • 1回复 待解决
HarmonyOS app后台提醒功能
230浏览 • 1回复 待解决
HarmonyOS中如何手动应用进入后台
224浏览 • 0回复 待解决
如何应用后台持续运行
17583浏览 • 2回复 待解决
APP如何主动返回手机桌面
588浏览 • 1回复 待解决