Actually the code.

A piece of service code:

class TestService : Service() inner class SigDataServiceBinder : Binder() { val service: TestService get() = this@TestService } fun test() { // что то делаем долгое } 

Actyvity attached to the service. And calls the "long" test () method.

 class TestServiceActivity : AppCompatActivity() { var boundService: TestService? = null // ..... fun callServiceMetod() { boundService?.test() } 

Such a test () call will occur in the main thread (which will slow down UI processing)?
If so, is there any point in doing so

 fun test() { Handler(mainLooper) .post { // что то делаем долгое } } 

How would you recommend handling long operations?

  • one
    IntentService, HandlerThread, AsyncTask, Kotlin Coroutines ... There are many options, take what you like. If you have a cotlin, I would recommend Coroutines - eugeneek

0