Android Screen Timeout

前端 未结 4 801
感情败类
感情败类 2020-11-30 06:45

I know its possible to use a wakelock to hold the screen, cpu, ect on but how can I programmatically change the \"Screen Timeout\" setting on an Android ph

4条回答
  •  余生分开走
    2020-11-30 07:35

    Here is a code-sheet, you can do more.

    long stand = Settings.System.getLong(
                            mContext.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT,
                            -1);
                    long sec = stand / 1000;
                    String time = null;
                                        if(stand<0) {
                                             //close.
                                        }
                    else if( sec >= 60) {//to minute
                        time = String.format(mContext.getString(R.string.minutes), (sec / 60) + "");
                    } else {
                        time = String.format( mContext.getString(R.string.seconds),sec + "");
                    }
    

提交回复
热议问题