小编Ila*_*lan的帖子

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

我正在寻找一种使用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
查看次数

从复杂字符串中检索整数

我有一个代码,可以读取某个文件的内容.该文件的开头如下:

J-549 J-628 J-379 J-073 J-980 vs J-548 J-034 J-127 J-625 J-667\
J-152 J-681 J-922 J-079 J-103 vs J-409 J-552 J-253 J-286 J-711\
J-934 J-367 J-549 J-169 J-569 vs J-407 J-429 J-445 J-935 J-578\
Run Code Online (Sandbox Code Playgroud)

我想将每个整数存储在一个大小为270(行数)x 10(每行的整数)的数组中.

我没有使用正确的正则表达式.这是我的一段代码:

String strLine;
int[] id = new int[10];//list ID of each line
//Read File Line By Line
while ((strLine = br.readLine()) != null)   {
    // Print the content on the console

    strLine = strLine.replaceAll("J-", "");
    strLine = strLine.replaceAll(" vs ", " ");
    String[] teamString …
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
1
解决办法
62
查看次数

标签 统计

android ×1

java ×1

night-shift ×1