change process priority in android

前端 未结 3 514
情歌与酒
情歌与酒 2020-12-31 12:47

How to change process priority in Android? I have found process description and description of it\'s priorities in android docs

process and thread description

<
相关标签:
3条回答
  • 2020-12-31 13:21

    This only works with a rooted device:

    Use a terminal, become root by inputting

        su
    

    then select the process-id from the output of top

        top -n 1 -m 10
    

    look in the column PID and renice the process (in this example PID 1825 to priority 0) you want to by

        renice 0 1825
    

    That's all. Keep in mind, that this change will be overwritten by the OperatingSystem, after some time, when OS thinks it was necessary to give the process more priority.

    0 讨论(0)
  • 2020-12-31 13:36

    How to change process priority in Android?

    You can't, except perhaps on a rooted device, and then only temporarily. Process priority is managed by the OS. If your app is in the foreground, it will run with foreground priority. If your app is not in the foreground, it will not run with foreground priority.

    I need this to test only some feature of application which is connected with process priority and it won't be used in program.

    Then test with a process that is in the foreground versus one that is not.

    The only way I see is to try to change the priority via importance field, but it's a bad idea I guess.

    Changing that number is unlikely to have an effect. RunningAppProcessInfo is an output structure, not a means by which to change anything reported via that structure.

    0 讨论(0)
  • 2020-12-31 13:41

    setpriority() and getPriority() in the native code exists, so may be we can set the priority from the native code. But, I am not sure whether it takes effect by the os or neglects it.

    0 讨论(0)
提交回复
热议问题