Android Question MEDIA_BUTTON with Android 7+ and API 26

scsjc

Well-Known Member
Licensed User
Longtime User
Have you added an intent filter with android.intent.action.MEDIA_BUTTON action?
Yes.... i put this intent filter but dont work.


in a debugger i quit a filter... and i see response when push key "keyCode=KEYCODE_MEDIA_PAUSE"
on bluetooth:

B4X:
SeisAVRCPProfileEnabled
Starting mediastore instant index
isSecureModeEnabled
getSecureModeSetting, name: secure_mode_enable
btavrcp_passthrough_command_callback
MSG_NATIVE_REQ_PASS_THROUGH: id=70 st=0
dispatchMediaKeyEvent, pid=4273, uid=1002, event=KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PAUSE, scanCode=0, metaState=0, flags=0x0, repeatCount=0, eventTime=0, downTime=0, deviceId=-1, displayId=0, source=0x0 }
getAudioPolicyConfig: hmtState
called by bluetooth, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PAUSE, scanCode=0, metaState=0, flags=0x0, repeatCount=0, eventTime=0, downTime=0, deviceId=-1, displayId=0, source=0x0 }
Sending KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PAUSE, scanCode=0, metaState=0, flags=0x0, repeatCount=0, eventTime=0, downTime=0, deviceId=-1, displayId=0, source=0x0 } to the last known PendingIntent PendingIntent{8b13bf8: PendingIntentRecord{d8c48d1 com.maxmpz.audioplayer broadcastIntent}}
recordKeyDispatched: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PAUSE, scanCode=0, metaState=0, flags=0x0, repeatCount=0, eventTime=0, downTime=0, deviceId=-1, displayId=0, source=0x0 } dispatched to com.maxmpz.audioplayer
!@   8,0 r 3494949 60253832 w 497309 7928596 d 43733 2295636 f 114460 127816 iot 1025364 859567 th 307200 0 0 pt 0 inp 0 0 19740.680
filterNetworkStateForUid() uid: 1000 networkInfo: [type: WIFI[] - WIFI, state: CONNECTED/CONNECTED, reason: (unspecified), extra: "jc", failover: false, available: true, roaming: false, metered: false]
getAudioPolicyConfig: audioParam;activeStream
### active stream : 8
active stream is 0x8
getAudioPolicyConfig: audioParam;outDevice
getNewOutputDevice() selected device 0
getDeviceForStrategy mLastPolicySelection device = 80
getNewOutputDevice() selected device 80
### curdevice : 80
 
Upvote 0

scsjc

Well-Known Member
Licensed User
Longtime User
If the app is visible then you should be able to catch this event with Activity_KeyPress.
I know, but it's because I'm using the app as background service.

Actually I solved the problem with an alternative, what I really needed was to save the current volume, and what I have done, is a timer in the service that every X if there is change in the volume of the android saves that variable.

Thank you
 
Upvote 0
Top