HarmonyOS 如何在APP内通过点击按钮跳转到通知设置页

1、想在APP内设置通知的打开与关闭,想直接跳到系统的通知设置页面,请问相关API是什么?

2、如何在程序内控制手机不黑屏,一直处于点亮状态。

HarmonyOS
2024-12-25 11:34:19
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

参考示例如下:

import { BusinessError } from '@kit.BasicServicesKit';
import { common, Want } from '@kit.AbilityKit';

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';

  build() {
    RelativeContainer() {
      Text(this.message)
        .id('HelloWorld')
        .fontSize(50)
        .fontWeight(FontWeight.Bold)
        .alignRules({
          center: { anchor: '__container__', align: VerticalAlign.Center },
          middle: { anchor: '__container__', align: HorizontalAlign.Center }
        })
        .onClick(() => {
          let context = getContext(this) as common.UIAbilityContext;
          const wantInfo: Want = {
            bundleName: 'com.huawei.hmos.settings',
            abilityName: 'com.huawei.hmos.settings.MainAbility',
            uri: 'systemui_notification_settings', // 通知和状态栏(需要用户手动选择应用)
            parameters: {
              pushParams: 'com.example.myapplication'//自己的应用
            }
          }
          context.startAbility(wantInfo)
            .then(() => {
              // do nothing
            }).catch((err: BusinessError) => {
            console.error('openLocationPermissionPage:', JSON.stringify(err));
          })
        })
    }
    .height('100%')
    .width('100%')
  }
}
  • 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.

设置屏幕是否为常亮状态可参考setWindowKeepScreenOn:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5#setwindowkeepscreenon9

分享
微博
QQ
微信
回复
2024-12-25 13:28:44
相关问题
如何跳转到APP设置和权限管理
1729浏览 • 1回复 待解决
如何跳转到app设置,有人知道吗?
1344浏览 • 1回复 待解决
HarmonyOS 如何跳转设置通知管理
615浏览 • 1回复 待解决
HarmonyOS 跳转到设置->通知管理的方法
672浏览 • 1回复 待解决
HarmonyOS app中怎么跳转到系统设置
1286浏览 • 1回复 待解决
HarmonyOS 如何跳转到系统位置开关
746浏览 • 1回复 待解决
鸿蒙APP如何跳转到Android APP
16434浏览 • 3回复 待解决
HarmonyOS app通知
788浏览 • 1回复 待解决
如何设置一个通知按钮
1307浏览 • 1回复 待解决
如何app跳转到系统相机
6442浏览 • 1回复 已解决
HarmonyOS 如何跳转到应用设置页面?
1200浏览 • 1回复 待解决