As you know, only one app can use the mic to record.
when i do a recording using b4a and then another app asks to record. the other app will not be able to record because i was already using the mic (like having a whatsapp/viber call in the middle of a recording).
is their is s way to detect if another app is requesting the mic so i could release it ?
MY project is something like cortana or siri , it keep listening to the audio through the mic all the time.
the problem is that if my app is using the mic all the time through service.
other apps like (whatsapp, viber ) will not be able to use the mic.
so in m project their is only a service the activity will only start the service and the app must still run when the service is paused
You can use this code to find the current running app:
B4X:
Sub CurrentRunningActivity As String
Try
Dim jo As JavaObject
jo.InitializeContext
jo = jo.RunMethod("getSystemService", Array("activity"))
Return jo.RunMethodJO("getRunningTasks", Array(1)).RunMethodJO("get", Array(0)).GetFieldJO("topActivity") _
.RunMethod("getPackageName", Null)
Catch
Log(LastException)
Return ""
End Try
End Sub
You can use this code to find the current running app:
B4X:
Sub CurrentRunningActivity As String
Try
Dim jo As JavaObject
jo.InitializeContext
jo = jo.RunMethod("getSystemService", Array("activity"))
Return jo.RunMethodJO("getRunningTasks", Array(1)).RunMethodJO("get", Array(0)).GetFieldJO("topActivity") _
.RunMethod("getPackageName", Null)
Catch
Log(LastException)
Return ""
End Try
End Sub
The problem i don't know the mic apps that the user could use.
Is their is a way to make b4a take the lowest priority for the mic ? so if any other app request the mic b4a will let it go..