[Android-development] Build an Android Launcher in Qt ...

David Marceau uticdmarceau2007 at yahoo.ca
Fri Feb 28 23:10:18 CET 2014


On 02/28/2014 04:53 PM, David Marceau wrote:
> On 02/28/2014 03:44 PM, Éric Seigne wrote:
>> Hello,
>>     int receiverRequestCode = -1;
>>     QAndroidJniObject intent = QAndroidJniObject::callStaticObjectMethod("com/my/app/name_two", "QtActivity","");
>>     QtAndroid::startActivity(intent, receiverRequestCode, 0);
>>
>> but i don't know what i have to use as first and second parameters of 
>> callStaticObjectMethod function ?
> https://github.com/omac777/qtsnowloadcount/blob/master/trucktypetotalspage.cpp#L59
> 
> https://github.com/omac777/qtsnowloadcount/blob/master/trucktypetotalspage.cpp#L72

I will clarify.  Here is the doc for the method you want to call:
http://qt-project.org/doc/qt-5/qandroidjniobject.html#callStaticObjectMethod-2

QAndroidJniObject QAndroidJniObject::callStaticObjectMethod(const char *
className, const char * methodName, const char * signature, ...) [static]
Calls the static method with methodName and signature on the class
className.
QAndroidJniObject thread =
QAndroidJniObject::callStaticObjectMethod("java/lang/Thread",
"currentThread", "()Ljava/lang/Thread;");
QAndroidJniObject string =
QAndroidJniObject::callStaticObjectMethod("java/lang/String", "valueOf",
"(I)Ljava/lang/String;", 10);

>>     QAndroidJniObject intent =
QAndroidJniObject::callStaticObjectMethod("com/my/app/name_two",
"QtActivity","");

className >>>> "com/my/app/name_two" >>>That's the java android class name
methodName >>>> QtActivity  >>>That's the java android method you want
to call from your cpp.

signature >>>That's the JNI signature for the method you are calling.
http://en.wikipedia.org/wiki/Java_Native_Interface#Mapping_types

To help you more it would be nice to see the java method you are
actually trying to call and it's original java declaration.  Provide me
with that and I will build the signature for you.

Cheers,
David Marceau
http://adequatech.ca
613.218.7497





More information about the Android-development mailing list