Multimedia control by Bluetooth

ManuelFG

Member
Licensed User
Longtime User
I have created a multimedia application for play/pause/FW/ music and I control it by captured bluetooth buttons. It work very well but...

The problem is that bluetooth simultaneously activates both multimedia, which is installed in Android "Music" and my own application.

How I can give preference to my application or how I can disable the program "Music" for the bluetooth commands which incorporates Adroid?

Thank
 

ManuelFG

Member
Licensed User
Longtime User
This is the way that I get the bluetooth button commands.

Please, can you tell me how I can give 1º priority to my applicatión?
Or disable the bluetooth events for a specifc application like Android "Music"?

Thank.

- - - - - - - - - - - - - - -

Sub Activity_KeyPress (KeyCode As Int) As Boolean

Select KeyCode
Case 87 'Forwared

Case 88 'Back

Case 85 'Play

Case 86 'Pause

Case 24 '+ Volumen Button Device

Case 25 '- Volumen Button Device

Case Else

End Select
 
Upvote 0

ManuelFG

Member
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should create a service.
In the manifest editor you should add:
B4X:
AddReceiverText(serviceName, 
                        <intent-filter android:priority="2147483647">
                                <action android:name="android.intent.action.MEDIA_BUTTON"/>
                        </intent-filter>
)

Service_Start will be called each time that a media button will be pressed.
The button value should be mapped to an extra with the key: android.intent.extra.KEY_EVENT
 
Upvote 0

ManuelFG

Member
Licensed User
Longtime User
Example

Hello Erel

Thank for your information but I do not understand very well how do.(I am a B4A novice)
Please, can you give a little more information or a small example for this.

Thank!
 
Upvote 0

ManuelFG

Member
Licensed User
Longtime User
Erel,
you said:
"Service_Start will be called each time that a media button will be pressed."
"The button value should be mapped to an extra with the key: android.intent.extra.KEY_EVENT"


Please, can you give me a example how mapped an extra key: android.intent.extra.KEY_EVENT?

Thank,

Manuel
 
Upvote 0
Top