Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 level below 28?

like image 225
Abhishek Jain Avatar asked Sep 02 '25 15:09

Abhishek Jain


1 Answers

You can use (in activity for example):

ContextCompat.getMainExecutor(this);

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

like image 60
antaki93 Avatar answered Sep 05 '25 05:09

antaki93