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

David Marceau uticdmarceau2007 at yahoo.ca
Fri Feb 28 23:34:36 CET 2014


On 02/28/2014 05:16 PM, Éric Seigne wrote:
> Le 28/02/2014 23:10, David Marceau a écrit :
>> 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.
> 
> Hello David,
> thanks a lot for helping me, but i'm a Qt/c++ only developper, there is
> 0 java code lines in app1 or app2 :o)
> 
> in other os i just make a qprocess to launch app2 from app1
> 
> Éric
> 

Eric,

Firstly, the QJNIObject as you know helps you to usually bridge java
higher-level stuff to lower-level c++ stuff.
What you're saying is everything is in c++, but in order to get AppA to
run App2 in Android,  both apps need to be Android compliant.
In order for them to be compliant they need some kind of bridging api
with jni call declarations or exports.  You must have created some jni
call declarations for both apps.  Right?
That third parameter signature is necessary be it c++/java-based for as
long as it is running within the android runtime environment:
http://en.wikipedia.org/wiki/Dalvik_%28software%29
because it is the android runtime environment controlling everything and
not your apps.  I hope this helps.

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




More information about the Android-development mailing list