@@ -86,7 +86,11 @@ impl AndroidAppWaker {
8686}
8787
8888impl AndroidApp {
89- pub ( crate ) fn new ( native_activity : NativeActivityGlue , jvm : CloneJavaVM ) -> Self {
89+ pub ( crate ) fn new (
90+ native_activity : NativeActivityGlue ,
91+ jvm : CloneJavaVM ,
92+ main_looper_ptr : * mut ndk_sys:: ALooper
93+ ) -> Self {
9094 let mut env = jvm. get_env ( ) . unwrap ( ) ; // We attach to the thread before creating the AndroidApp
9195
9296 let key_map_binding = match KeyCharacterMapBinding :: new ( & mut env) {
@@ -103,6 +107,9 @@ impl AndroidApp {
103107 looper : Looper {
104108 ptr : ptr:: null_mut ( ) ,
105109 } ,
110+ main_looper : Looper {
111+ ptr : main_looper_ptr,
112+ } ,
106113 key_map_binding : Arc :: new ( key_map_binding) ,
107114 key_maps : Mutex :: new ( HashMap :: new ( ) ) ,
108115 input_receiver : Mutex :: new ( None ) ,
@@ -147,6 +154,9 @@ pub(crate) struct AndroidAppInner {
147154 pub ( crate ) native_activity : NativeActivityGlue ,
148155 looper : Looper ,
149156
157+ /// Looper associated with the activy's main thread, sometimes called the UI thread.
158+ main_looper : Looper ,
159+
150160 /// Shared JNI bindings for the `KeyCharacterMap` class
151161 key_map_binding : Arc < KeyCharacterMapBinding > ,
152162
@@ -179,6 +189,10 @@ impl AndroidAppInner {
179189 self . looper . ptr
180190 }
181191
192+ pub fn main_looper ( & self ) -> * mut ndk_sys:: ALooper {
193+ self . main_looper . ptr
194+ }
195+
182196 pub fn native_window ( & self ) -> Option < NativeWindow > {
183197 self . native_activity . mutex . lock ( ) . unwrap ( ) . window . clone ( )
184198 }
0 commit comments