Merge: Added `copy_from` service to `NativeString`
[nit.git] / lib / android / http_request.nit
index d7427c3..d4e9b0f 100644 (file)
@@ -30,7 +30,15 @@ in "Java" `{
 `}
 
 redef class App
-       redef fun run_on_ui_thread(task) do app.native_activity.run_on_ui_thread task
+       redef fun run_on_ui_thread(task)
+       do
+               if app.activities.not_empty then
+                       app.native_activity.run_on_ui_thread task
+               else
+                       # There is no UI, it must be a service, run on the caller thread
+                       task.main
+               end
+       end
 end
 
 redef class Text
@@ -102,3 +110,8 @@ private extern class JavaHttpResponse in "Java" `{ org.apache.http.HttpResponse
                }
        `}
 end
+
+# Force linearization of print
+#
+# TODO prioritize `android::log`
+redef fun print(object) do super