如何在API级别<上获取主线程的执行器28岁 [英] How to get Executor for main thread on API level < 28

查看:92
本文介绍了如何在API级别<上获取主线程的执行器28岁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在API级别28(Pie)上,在 Context 类中引入了一种新方法,以获取主线程

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

如何使此执行程序的API级别低于28?

How to get this executor on API level below 28?

推荐答案

您可以使用(例如,在活动中):

You can use (in activity for example):

ContextCompat.getMainExecutor(this);

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

这篇关于如何在API级别<上获取主线程的执行器28岁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆