Middle
22
0
questionbank

Можно ли подключиться к сервису, если Activity запускается после него?

Answer from sobes.tech neural network

Да, можно, используя Context и Binding.

  1. Создать Service: Наследуется от Service (или IntentService/JobIntentService). Реализовать onBind(Intent intent) который возвращает IBinder.

    kotlin
  2. Подключиться из Activity: Использовать Context.bindService(). Реализовать ServiceConnection.

    kotlin

Да, можно, используя Context и Binding.

  1. Создать Service: Наследуется от Service (или IntentService/JobIntentService). Реализовать onBind(Intent intent) который возвращает IBinder.

    kotlin
  2. Подключиться из Activity: Использовать Context.bindService(). Реализовать ServiceConnection.

    kotlin

Register or sign in to get access to full answers for all questions from the question bank.

androidactivityservice-bindinginter-process-communication