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

Stromme Christian Christian.Stromme at digia.com
Fri Jan 10 13:15:23 CET 2014


On 10 Jan 2014, at 07:42 , Mikhail Khvoinitsky <mhspacee at gmail.com> wrote:

> Excuse for the late answer.
> I've got it to work and I have some notes.
> The documentation for QAndroidJniObject is not enough clear:
>  * Some methods like QAndroidJniObject::getStaticObjectField are 
> templates but it isn't specified in documentation at all. Also, choosing 
> the overloaded method depends on template type. Right now the only way 
> to learn about it is sources.

The use of templet types to deduce the signature is mention under the section "Method Signatures" (http://doc-snapshot.qt-project.org/qt5-stable/qandroidjniobject.html#method-signatures),
but I see that it might not be descriptive enough.

>  * In the doc of QAndroidJniObject (Detailed Description > JNI Types > 
> Object Types) said that the signature of jobject is 
> «L<fully-qulified-name>};» but it seems misspelled and should be 
> «"L<fully-qulified-name>;”»

The bracket near the end was an unfortunate typo and have already been fixed: 
http://doc-snapshot.qt-project.org/qt5-stable/qandroidjniobject.html#object-types

(A patch to fix the misspelling of “qualified" is pending for review).

> 
> On 01/03/2014 10:57 AM, Eskil Abrahamsen Blomfeldt wrote:
>> 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.
> _______________________________________________
> Android-development mailing list
> Android-development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/android-development




More information about the Android-development mailing list