How to use activity-alias to manage app arguments
Solved
Mobile and Embedded
-
I'm building a Qt application using cmake for android platform.
I would like to have 2 intent launchers.
Each launcher has its own arguments.activity-alias seems to be adequate to do that:
<activity-alias android:name=".FullscreenAlias" android:targetActivity="org.qtproject.qt.android.bindings.QtActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="android.app.arguments" android:value="--fullscreen" /> </activity-alias>
I run like this:
adb shell am start -n com.sample.app/org.qtproject.qt.android.bindings.QtActivity # OK
adb shell am start -n com.sample.app/.FullscreenAlias # NOKI got the following error message:
"Your application encountered a fatal error and cannot continue."I guess the related logs are:
10-30 14:30:24.956 7247 7247 W System : ClassLoader referenced unknown path: 10-30 14:30:24.969 7247 7269 W System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.Bundle.containsKey(java.lang.String)' on a null object reference 10-30 14:30:24.969 7247 7269 W System.err: at org.qtproject.qt.android.QtNative$4.run(QtNative.java:292) 10-30 14:30:24.969 7247 7269 W System.err: at org.qtproject.qt.android.QtThread$2.run(QtThread.java:51) 10-30 14:30:24.969 7247 7269 W System.err: at org.qtproject.qt.android.QtThread$1.run(QtThread.java:25) 10-30 14:30:24.969 7247 7269 W System.err: at java.lang.Thread.run(Thread.java:920) 10-30 14:30:24.970 7247 7247 W System.err: java.lang.Exception: 10-30 14:30:24.970 7247 7247 W System.err: at org.qtproject.qt.android.bindings.QtLoader.loadApplication(QtLoader.java:188) 10-30 14:30:24.970 7247 7247 W System.err: at org.qtproject.qt.android.bindings.QtLoader.startApp(QtLoader.java:374) 10-30 14:30:24.970 7247 7247 W System.err: at org.qtproject.qt.android.bindings.QtActivityLoader.onCreate(QtActivityLoader.java:114) 10-30 14:30:24.970 7247 7247 W System.err: at org.qtproject.qt.android.bindings.QtActivity.onCreateHook(QtActivity.java:237) 10-30 14:30:24.970 7247 7247 W System.err: at org.qtproject.qt.android.bindings.QtActivity.onCreate(QtActivity.java:257) 10-30 14:30:24.970 7247 7247 W System.err: at android.app.Activity.performCreate(Activity.java:8050) 10-30 14:30:24.970 7247 7247 W System.err: at android.app.Activity.performCreate(Activity.java:8030) 10-30 14:30:24.970 7247 7247 W System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329) 10-30 14:30:24.970 7247 7247 W System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3648) 10-30 14:30:24.970 7247 7247 W System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3832) 10-30 14:30:24.970 7247 7247 W System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
Do you know what is wrong and how to launch Qt app with 2 launchers/arguments?
-
Hello,
You need to configure more parameters inside your activity-alias
<activity-alias android:name=".Test" android:enabled="true" android:exported="true" android:label="-- %%INSERT_APP_NAME%% --" android:targetActivity="org.qtproject.qt.android.bindings.QtActivity">
Add copy all meta-data needed by the default activity to start
-