Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 125
Registered: ‎11-05-2011
My Device: Z10, Bold 9900
My Carrier: Smartone

Cannot detect when a Media Key is released (e.g. Volume up key)

[ Edited ]

I am trying to detect when a Media Key (e.g. Volume up) is pressed and released. 

 

I can receive the longPress signal from MediaKeyWatcher from MediaKey::VolumeUp after the key is pressed for a while. However, I don't receive any signal when the key is released.

 

I have tried both setNotification(MediaKeyNotification::Threshold) and setNotification(MediaKeyNotification::Clicked), but they behave the same to me. 

 

I am testing on Z10STL100-2/10.2.0.1793 and BlackBerry Native SDK 10.2.

 

Is it a bug? Is there any workaround? Thank you.

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Cannot detect when a Media Key is released (e.g. Volume up key)

Clicked should cause the signal to be emitted when the hardware key is released, if that's not happening, it sounds like a bug. Can you provide some sample code?

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Highlighted
Developer
Posts: 125
Registered: ‎11-05-2011
My Device: Z10, Bold 9900
My Carrier: Smartone

Re: Cannot detect when a Media Key is released (e.g. Volume up key)

My sample code is just like:

 

MediaKeyWatcher* keyWatcher = new MediaKeyWatcher(MediaKey::VolumeUp);
keyWatcher->setNotification(MediaKeyNotification::Clicked);

 

QObject::connect(keyWatcher, SIGNAL(longPress(bb::multimedia::MediaKey::Type)), this, SLOT(onLongPress(bb::multimedia::MediaKey::Type)));

 

void ApplicationUI:Smiley SurprisednLongPress(bb::multimedia::MediaKey::Type type)
{
  qWarning() << "onLongPress: " << type << endl;
}

 

I found onLongPress is triggered after pressing for a threshold, no matter if I use MediaKeyNotification::Clicked or not.

 

If it's confirmed a bug, is there another API to detect the MediaKey? At QT level? Thanks.