@@ -86,7 +86,7 @@ impl AndroidAppWaker {
8686}
8787
8888impl AndroidApp {
89- pub ( crate ) fn new ( native_activity : NativeActivityGlue , jvm : CloneJavaVM ) -> Self {
89+ pub ( crate ) fn new ( native_activity : NativeActivityGlue , jvm : CloneJavaVM , main_looper_ptr : * mut ndk_sys :: ALooper ) -> Self {
9090 let mut env = jvm. get_env ( ) . unwrap ( ) ; // We attach to the thread before creating the AndroidApp
9191
9292 let key_map_binding = match KeyCharacterMapBinding :: new ( & mut env) {
@@ -103,6 +103,9 @@ impl AndroidApp {
103103 looper : Looper {
104104 ptr : ptr:: null_mut ( ) ,
105105 } ,
106+ main_looper : Looper {
107+ ptr : main_looper_ptr
108+ } ,
106109 key_map_binding : Arc :: new ( key_map_binding) ,
107110 key_maps : Mutex :: new ( HashMap :: new ( ) ) ,
108111 input_receiver : Mutex :: new ( None ) ,
@@ -147,6 +150,9 @@ pub(crate) struct AndroidAppInner {
147150 pub ( crate ) native_activity : NativeActivityGlue ,
148151 looper : Looper ,
149152
153+ /// Looper associated with the activy's main thread, sometimes called the UI thread.
154+ main_looper : Looper ,
155+
150156 /// Shared JNI bindings for the `KeyCharacterMap` class
151157 key_map_binding : Arc < KeyCharacterMapBinding > ,
152158
@@ -179,6 +185,10 @@ impl AndroidAppInner {
179185 self . looper . ptr
180186 }
181187
188+ pub fn main_looper ( & self ) -> * mut ndk_sys:: ALooper {
189+ self . main_looper . ptr
190+ }
191+
182192 pub fn native_window ( & self ) -> Option < NativeWindow > {
183193 self . native_activity . mutex . lock ( ) . unwrap ( ) . window . clone ( )
184194 }
0 commit comments