[Android-development] How to get device or Android version?

Eskil Abrahamsen Blomfeldt eskil.abrahamsen-blomfeldt at theqtcompany.com
Fri Dec 12 09:48:11 CET 2014


On 12/11/2014 06:14 PM, Harri Pasanen wrote:
> I've been testing a bit with Kindler Fire HD 7 2nd gen, which is based
> on Android 4.0.3.
>
> It mostly works, but some things behave oddly.
> For instance, MessageDialog is unusable, it renders fullscreen near
> black on black text.   I'm not sure if the is the general Android 4.0.3
> experience, or due to some Amazon customization.
>
> I'm not sure if it is worth it to submit a bug report, Android 4.0.x is
> pretty old and this may be Kindle Fire specific.
>
> I could work around this by doing my own fallback MessageDialog, but I'd
> like to use my fallback only if Android version is less that 4.2, or a
> specific device is used, etc.
>
> Is there some Qt C++ or QML way to pull the OS version and device info,
> or do I need to go native on this one?

Hi,

You can get the OS version and some other info using QSysInfo:

     http://doc.qt.io/qt-5/qsysinfo.html

To find out what the specific device is, you would currently have to 
resort to JNI.

About the black-on-black text, we did have a bug like that during the 
release process, but it was fixed for the final release. I assume you 
are using the release packages? If that's the case, then it's probably 
related to that bug. You could work around this by forcing the Fusion 
style at the very beginning of your main() function, which should make 
the applications look as they did in Qt 5.3.2. Add 
QApplication::setStyle("fusion") before initializing QApplication. Or it 
would probably be possible to manually override the application palette 
with something that works.

But please also report all bugs in http://bugreports.qt-project.org or 
via Qt Support. The ones that are only reported here will likely never 
be addressed because they never enter any developer work flows. :)

-- Eskil




More information about the Android-development mailing list