File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
android/app/src/main/java/betaflight/configurator/plugin Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -104,14 +104,18 @@ public void receive(PluginCall call) {
104104 call .reject ("Not connected to any server" );
105105 return ;
106106 }
107- try {
108- String data = reader .readLine ();
109- JSObject ret = new JSObject ();
110- ret .put ("data" , data );
111- call .resolve (ret );
112- } catch (Exception e ) {
113- call .reject ("Receive failed: " + e .getMessage ());
114- }
107+
108+ // Run read operation on a background thread to avoid blocking the UI
109+ getBridge ().getExecutor ().execute (() -> {
110+ try {
111+ String data = reader .readLine ();
112+ JSObject ret = new JSObject ();
113+ ret .put ("data" , data );
114+ call .resolve (ret );
115+ } catch (Exception e ) {
116+ call .reject ("Receive failed: " + e .getMessage ());
117+ }
118+ });
115119 }
116120
117121 @ PluginMethod
You can’t perform that action at this time.
0 commit comments