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

Eric Seigne eric.seigne at ryxeo.com
Wed Mar 5 22:37:14 CET 2014


David, Others
i'm sorry but it does not work, i read all the documentation but i'm not 
a java dev and my problem seems too simple ... i'm looking at a too 
complicated solution i think !

easy question:
  clic on a button from QApplication "app_one" launch QApplication "app_two"

on windows and linux i have to use QProcess. Exec command is based on 
exec file name, "app_two.exe" for example

on android i have to use Intent. Intent is defined in 
AndroidManifest.xml, for example

<manifest package="*com.my.app.name_two*" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:versionName="1.0" android:versionCode="1" 
android:installLocation="auto">
     <application 
android:name="org.qtproject.qt5.android.bindings.QtApplication" 
android:hardwareAccelerated="true" android:label="app2">
         <activity android:screenOrientation="unspecified" 
android:name="*org.qtproject.qt5.android.bindings.QtActivity*" 
android:configChanges="orientation|uiMode|screenLayout|screenSize|small
estScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" 
android:label="@string/app_name">

so, i tried to run

     QAndroidJniObject myAppManager = 
QAndroidJniObject::callStaticObjectMethod<jstring>("com/my/app/name_two", "org.qtproject.qt5.android.bindings.QtActivity");
     myAppManager.callMethod<void>("QtActivity");

but ... it does not work :-(

i'm lost :o)

Éric

Le 01/03/2014 00:37, David Marceau a écrit :
> On 02/28/2014 06:18 PM, David Marceau wrote:
>> Ok, firstly you need to know how to launch other applications in android:
>> http://stackoverflow.com/questions/3872063/android-launch-an-application-from-another-application
>>
>> Now you have to take the recipe you find most fitting and translate it
>> into a cpp function call.  the QAndroidJniObject is definitely the right
>> class to use for you to get there.
>> http://qt-project.org/doc/qt-5/qandroidjniobject.html#QAndroidJniObject
>>
>> Your app1 is the one that will have to create a jnienvironment:
>> QAndroidJniEnvironment env;
>>
>> //The Java code looks like this:
>> //you do know the android mainactivity entry point
>> //packagename >>>"com.my.app.name_two"
>> //MainActivity name >>> "org.qtproject.qt5.android.bindings.QtActivity"
>> //Intent intent = new Intent(Intent.ACTION_MAIN);
> QAndroidJniObject app2Intent = NULL;
>
> class name full path: android.content.Intent
> necessary string constant name full path: android.content.Intent.ACTION_MAIN
>
> Intent Constructor declaration:
> Intent(String action)
>
>> //intent.setComponent(new
>> //ComponentName("com.my.app.name_two","org.qtproject.qt5.android.bindings.QtActivity"));
> setComponent declaration:
> public Intent setComponent (ComponentName component)
>
>> //startActivity(intent);
> You can see where I am going with this.
> The end result is something like:
> https://github.com/omac777/qtsnowloadcount/blob/master/trucktypetotalspage.cpp#L59
>
>
>> I extracted that information from your app2 AndroidManifest.xml
>>
>> Cheers,
>> David Marceau
>> http://adequatech.ca
>>
>>
>> On 02/28/2014 05:34 PM, Éric Seigne wrote:
>>> Hello,
>>> here is my "proof of concept" ...
>>>
>>> if you could extract, build and explain to me what i'm doing wrong ?
>> You can't use the standard c++ exec() within the Android Runtime
>> Environment because it is not a running the Posix Standard Runtime in
>> Android.  It is running other runtime environment depending on your
>> Android version. Dalvik or Art or whatever else as mentioned in the
>> previous email.
>>
>> You have to rely on the QAndroidJniObject to get you there.  You
>> translate every line of java above into something from QAndroidJniObject
>> calls can understand.
>>
>>
>>> thanks,
>>> Éric
>>>
>>> Le 28/02/2014 23:16, Éric Seigne a écrit :
>>>> 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
>>>
>>>
>>> _______________________________________________
>>> Android-development mailing list
>>> Android-development at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/android-development
>>>
> _______________________________________________
> Android-development mailing list
> Android-development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/android-development

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20140305/f65b4912/attachment.html>


More information about the Android-development mailing list