标签: night-shift

如何在macOS/iOS上观察夜班的变化?

我正在寻找一种方法来确定何时启用或禁用夜班,并基于此执行操作.我目前正在使用CoreBrightness框架中的CBBlueLightClient标头来控制夜班.这是我在我的应用中使用的部分标题:

@interface CBBlueLightClient : NSObject
- (BOOL)setStrength:(float)strength commit:(BOOL)commit;
- (BOOL)setEnabled:(BOOL)enabled;
- (BOOL)getStrength:(float*)strength;
- (BOOL)getBlueLightStatus:(struct { BOOL x1; BOOL x2; BOOL x3; int x4; struct { struct { int x_1_2_1; int x_1_2_2; } x_5_1_1; struct {
 int x_2_2_1; int x_2_2_2; } x_5_1_2; } x5; unsigned long x6; }*)arg1;
 @end
Run Code Online (Sandbox Code Playgroud)

CBBlueLightClient也有一个通知块,- (void)setStatusNotificationBlock:(id /* block */)arg1;我无法弄清楚如何使用.

这是iOS的完整标题.我尝试过的所有内容都适用于macOS,包括似乎存在的通知块.我只是无法弄清楚它期待什么样的闭合.

macos iphone-privateapi ios night-shift

6
推荐指数
1
解决办法
681
查看次数

如何以编程方式启用夜间模式?

我正在寻找一种使用Android代码以编程方式启用夜间模式的方法:

public static void setNightMode(Context target , boolean state){

    UiModeManager uiManager = (UiModeManager) target.getSystemService(Context.UI_MODE_SERVICE);

    if (state) {
        //uiManager.enableCarMode(0);
        uiManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
    } else {
       // uiManager.disableCarMode(0);
        uiManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
    }
}
Run Code Online (Sandbox Code Playgroud)

屏幕上没有任何变化,夜间模式仍处于禁用状态。根据这个链接

无需启用carMode或deskMode。我在Android Studio上有以下logcat:

11-26 12:15:16.662 3823-3823/? D/UiModeManager: updateConfigurationLocked: mDockState=0; mCarMode=false; mNightMode=2; uiMode=33
11-26 12:15:26.802 3823-3823/? V/UiModeManager: updateLocked: null action, mDockState=0, category=null
Run Code Online (Sandbox Code Playgroud)

android night-shift

5
推荐指数
3
解决办法
2998
查看次数

标签 统计

night-shift ×2

android ×1

ios ×1

iphone-privateapi ×1

macos ×1