[solved] Android volume control
-
wrote on 4 Jul 2014, 11:23 last edited by
Is it possible to change system volume on android?
Like in java:
@
AudioManager mgr=null;mgr=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
mgr.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
@ -
Hi,
AFAIK, there's no inbuilt way in Qt. You will have to rely on the Android API's. For it you will need to call Android API's from Qt.
Have a look at "qtandroidextras":http://qt-project.org/doc/qt-5/qtandroidextras-module.html and "qandroidjniobject":http://qt-project.org/doc/qt-5/qandroidjniobject.html. Also an example "here":http://qt-project.org/doc/qt-5/qtandroidextras-notification-example.html -
wrote on 4 Jul 2014, 12:01 last edited by
[quote author="p3c0" date="1404474027"]Hi, AFAIK, there's no inbuilt way in Qt. You will have to rely on the Android API's. For it you will need to call Android API's from Qt. Have a look at "qtandroidextras":http://qt-project.org/doc/qt-5/qtandroidextras-module.html and "qandroidjniobject":http://qt-project.org/doc/qt-5/qandroidjniobject.html. Also an example "here":http://qt-project.org/doc/qt-5/qtandroidextras-notification-example.html[/quote]
Thx!
I will have a closer look into it.
I wonder is there a function in android ndk I could wrap as a qml component and use it in qml to adjust system volume.
-
I don't think so android would allow it directly unless the system is rooted and more if a such a C function exists.
-
wrote on 6 Jul 2014, 07:43 last edited by
You can easily use QtAndroidExtras to call from C++ your java method, and then you can wrap the QtAndroidExtras into a QObject and export it to QML side.
I did it for other stuffs and works great.[quote author="habamax" date="1404475287"][quote author="p3c0" date="1404474027"]Hi, AFAIK, there's no inbuilt way in Qt. You will have to rely on the Android API's. For it you will need to call Android API's from Qt. Have a look at "qtandroidextras":http://qt-project.org/doc/qt-5/qtandroidextras-module.html and "qandroidjniobject":http://qt-project.org/doc/qt-5/qandroidjniobject.html. Also an example "here":http://qt-project.org/doc/qt-5/qtandroidextras-notification-example.html[/quote]
Thx!
I will have a closer look into it.
I wonder is there a function in android ndk I could wrap as a qml component and use it in qml to adjust system volume.
[/quote]
1/5