<html><head></head><body><div><strong><div style="display: inline !important;"><strong>From:
</strong>
 
Tomasz Bojczuk <seelook@gmail.com> </div></strong></div><div>
<strong>
To:
</strong>
 
<android-development@qt-project.org>
<br>
<strong>
Sent:
 
</strong>
10/18/2016 9:28 AM
<br>
<strong>
Subject:
</strong>
 
[Android-development] Handling Android volume keys
<br><br><blockquote class="mcntmori" style="margin:0 0 0 .8ex;border-left:1px solid #CCC;padding-left:1ex;"><div>Hi,<br><br>QKeyEvent doesn't support Android volume keys. How to handle them then?<br>I found Java code:<br><br>@Override<br>public boolean dispatchKeyEvent(KeyEvent event) {<br>    int action = event.getAction();<br>    int keyCode = event.getKeyCode();<br>    switch (keyCode) {<br>        case KeyEvent.KEYCODE_VOLUME_UP:<br>            if (action == KeyEvent.ACTION_DOWN) {<br>                // emit something for c++<br>            }<br>            return true;<br>        case KeyEvent.KEYCODE_VOLUME_DOWN:<br>            if (action == KeyEvent.ACTION_DOWN) {<br>                // emit something for c++<br>            }<br>            return true;<br>        default:<br>            return super.dispatchKeyEvent(event);<br>    }<br>}<br><div><br></div><div>and with available "Android on Qt "episodes I hope to be able to call my c++ part from that. </div><div>But how and where the above code should be run?</div></div></blockquote></div><div><br></div><div>Hi,</div><div><br></div><div>This code should be put into your applications' activity Java code. Your activity will need to inherit from QtActivity.</div><div>You'll also need to add static native methods to your activity which you call in the appropriate case. </div><div>That allows you to make the transition into the C++ part of your application which registers its functions with the JNI in JNI_OnLoad (see <a href="https://www.kdab.com/qt-android-episode-5/" title="https://www.kdab.com/qt-android-episode-5/" target="_blank">https://www.kdab.com/qt-android-episode-5/</a>).</div><div><br></div><div>Btw: the 'development' mailing list is for the development of Qt itself, you should post to the 'interest' mailing list.</div><br><div><blockquote class="mcntmori" style="margin:0 0 0 .8ex;border-left:1px solid #CCC;padding-left:1ex;"><div><div></div><div><br></div><div>Regards</div><div>Tomasz</div></div>
<br><br>_______________________________________________
<br>Android-development mailing list
<br>Android-development@qt-project.org
<br>http://lists.qt-project.org/mailman/listinfo/android-development</blockquote></div><div><blockquote class="mcntmori" style="margin:0 0 0 .8ex;border-left:1px solid #CCC;padding-left:1ex;"><br></blockquote></div></body></html>