[Android-development] Getting an Activity instance from C++ code

Eskil Abrahamsen Blomfeldt eskil.abrahamsen-blomfeldt at digia.com
Fri Jan 3 08:57:11 CET 2014


On 01/03/2014 06:37 AM, Mikhail Khvoinitsky wrote:
> Hello.
>
> I am using Qt 5.2.
> How I can get the Activity instance from C++ code?
> I have tried this solution http://qt-project.org/forums/viewthread/33771
> but it isn't working for me (may be it works only in qt 5.1)

Getting it in the way described there should still work in Qt 5.2, but 
it's undocumented and not part of the public API, so anyone using it 
should be clear that behavior could change in future releases.

>
> Also, I did find something about activity in Qt Android Extras
> documentation.
>
> Note: My Activity is a subclass of Qt's QtActivity.

If your application only has a single activity, set a reference to it in 
the constructor of your Java class, add an accessor for this and call it 
using JNI. Qt Android Extras might help with the JNI part.

-- Eskil




More information about the Android-development mailing list