How do I post code to be run on the Android main thread from a separate thread in C++?

后端 未结 5 1360
我寻月下人不归
我寻月下人不归 2021-01-07 17:55

I have a separate thread running in C++ in the background and I want it to be able to post code to be run on another thread that\'s already running an android.os.Looper (e.g

5条回答
  •  攒了一身酷
    2021-01-07 18:03

    You need a function already executed in the main thread. If you call ALooper_forThread() or ALooper_prepare() there, you will get a pointer to looper associated with main thread. Remember to call ALooper_acquire() so it can be shared among different threads.

提交回复
热议问题