0

i want to find a way to activate microphone in the background, so the case is, i dont want to listen to microphone in background always for battery reasons, what i want to do instead is to activate microphone in the another background process whenever i need it and end the process shortly after (based on triggers) i want to know is this possible with both android and ios?

It would be good if the answer is expo compatible, but react-native or swift solution would be good as well (if they exist)

Thanks

iLiA
  • 3,053
  • 4
  • 23
  • 45
  • Remember that in newer versions of android background services can stand only for some seconds if you need a service that last for more time you need to use a foreground service – Z3R0 Jun 21 '22 at 04:54
  • You mean like background service process is launched and dies in few seconds in an interval of time? – iLiA Jun 21 '22 at 11:51
  • sorry background service can last minutes not seconds. For example: "When an app goes into the background, it has a window of several minutes in which it is still allowed to create and use services." I don't remember how much time now, but I remember that when I tryed it to works with BLE it doesn't last too much, after a few it stopped working – Z3R0 Jun 21 '22 at 12:17
  • So if you're service works for more times you should use a foreground service https://developer.android.com/about/versions/oreo/background – Z3R0 Jun 21 '22 at 12:19
  • But how does location services work then – iLiA Jun 26 '22 at 00:00
  • For location in background from Android version 10 and up you need to use and request the permission BACKGROUND_LOCATION. If the location is in a Foreground Service you can specify the foreground service as of type "location" in the manifest. Like "android:foregroundServiceType="location""in this way you don't need the BACKGROUND_LOCATION permission. If you use background service to get location without the permission it doesn't work (you can try) if you use a foreground service with the type setted to "location" it works. – Z3R0 Jun 26 '22 at 12:56
  • Remember that if your app is uploaded into the play store and you use BACKGROUND_LOCATION you need to follow the policies of GOogle about background location. So you need to modify your privacy policies and talk about background location data acquired on it and also you need to display a dialog message about the usage of the background location in your app. Foreground services can last whatever you want it last. https://developer.android.com/guide/components/foreground-services – Z3R0 Jun 26 '22 at 12:58
  • https://stackoverflow.com/questions/15758980/android-service-needs-to-run-always-never-pause-or-stop – Z3R0 Jun 26 '22 at 13:05

1 Answers1

0

This actually works, like most internet calling software, but only if you have permission to access the microphone.

Joe199382
  • 199
  • 1
  • 12
  • Yeah but doesn’t internet calling softwares just always have microphone in the background while having a conversation? – iLiA Jun 21 '22 at 11:53
  • You can also choose to turn off the microphone signal, just like the mute function. Of course you can also activate the microphone signal when needed – Joe199382 Jun 21 '22 at 12:52
  • And it won’t drain the battery? – iLiA Jun 26 '22 at 00:00
  • You can choose to establish a call connection when you need it and disconnect it when you don't need it, or stay connected at the beginning and turn off the audio when you don't need it. The difference between the two is latency and power consumption. – Joe199382 Jun 26 '22 at 03:49