How to get Executor for main thread on API level < 28

后端 未结 3 1874
梦谈多话
梦谈多话 2021-02-07 16:25

On API level 28(Pie) a new method is introduced in the Context class to get Executor for the main thread getMainExecutor().

How to get this executor on API

3条回答
  •  醉梦人生
    2021-02-07 16:45

    You can use (in activity for example):

    ContextCompat.getMainExecutor(this);
    

    https://developer.android.com/reference/androidx/core/content/ContextCompat.html#getMainExecutor(android.content.Context)

提交回复
热议问题