Integrate a second application (open an non App Inventor app from an App Inventor app)

what command should I use to open another application with Activity Starter?

See Using the Activity Starter (App Inventor 2)

If you want an extension:

You will need to know the application package name for “Zettle”. You can work something out with this extension, with the LaunchApp block.

The instructions in the ActivityStarter documentation are a little ambiguous. I annotated the existing information in Bold text; the additional information might help you to start 'zettle'

The documentation instructions are not very clear for working with non-App Inventor apps. Perhaps @EWPATTON can help? Can you make this more clear Evan? Do you have an example?

Appendix: Technical information for Android developers who are designing external apps for use with App Inventor apps

If you build Android apps using the Android SDK, you can design external apps that start App Inventor apps and you can also design apps can be started by App Inventor apps. You can also arrange to pass values between the App Inventor apps and the external apps.

Returning results from external apps to App Inventor apps
The AndExplorer example The AndExplorer example at Using the Activity Starter (AI Classic) using Classic App inventor shows how external apps can make results available as properties of the Activity Starter when the app terminates. In the case of AndExplorer, the properties were ResultType and ResultUri. To know this information about AndExplorer, you’d need to find documentation for AndExplorer or see examples of Android code that uses it.

In general when your external app finishes and returns an intent to the App Inventor app that started it, the value of Intent.type() will be available as the ActivityStarter.ResultType property. Similarly, the will be the value of Intent.getDataString() will be available as the ResultUri property.

You can also pass back other information in the intent. Choose a name (Java String) for the result and have the App Inventor apps set that name to be the ResultName property of the activity starter. To return a desired value from your external app in an intent, use Intent.putextra(chosenResultName, desiredValue). When your external app finishes, the App Inventor ActivityStarter.AfterActivity() event will be signalled, and the result parameter to event handler will be the desired value. That same desired value will also be available as the Activity Starter’s Result property. The desired value must be a string, and you can return only one value using this method.

Starting App Inventor apps from external apps
To start an App Inventor activity from an external app, use the Java Android methods startActitvity() or startActivityForResult(). To pass a startup value, include that value in the intent, by invoking the method Intent.putExtra(tag, value) where tag is the string APP_INVENTOR_START. The App Inventor app being started can then access the corresponding value with the screen’s Get Start Plain Start Text method.

Returning results from App Inventor apps to external apps
When the App Inventor app that you started finishes (more technically, when the current screen closes with CloseScreen), it will signal onActivityResult() to the external app that started it. The App Inventor app can pass back a text string value by using Close Screen With Plain Text. That value will be available to the external app through the returned Intent as Intent.getStringExtra(APP_INVENTOR_RESULT).

:thinking: :face_with_raised_eyebrow:

can someone give an example I am not so competent thanks

pleae follow chapter "Discovering how to set the ActivityStarter properties" from the link provided earlier, here is it again Using the Activity Starter

Discovering how to set the ActivityStarter properties

If you want to start an app and you you don't have the source code or documentation, you might still be able figure out the package name and class name (and sometimes the intent) by launching the app and inspecting the Android system log.

For example, if you use the YouTube application to play a video, you'll see in the log:

I/ActivityManager( 86): Starting activity: Intent { act=android.intent.action.VIEW }

If you can find the "cmp=" string, then the ActivityPackage is the part before the slash, e.g., The ActivityClass is is the entire "cmp=" part, without the slash character, e.g., There may also in general be "dat=" information that should be specify as the DataUri property.

How to inspect the log see also here


Try this: launchZettle.aia (22.2 KB)

I used a new extension that declares a required permission for Android 11+.
So build the APK and try. (Make sure Zettle app is installed first.)



It runs well for launching my app, but how can I know the packageName for others apps?

Exactly as I showed in the first block.

1 Like

Anke's solution is much better than Package Manager Extension :+1: :+1:
There is also a way with activity starter ?

Yes there is.. for example ...


Thanks, it runs for Ai2 apps, can I use the same sintax for others apps ?

Yes you can

1 Like

Thanks, I think Anke's way is more simple

1 Like

How can I export this extension from your project ?

1 Like

Hi thanks I tried your example and it works but where can I download the extension? Is there a way to send the total to be paid directly on the zettlz application?

Here you go:
AllPackages.aix (4.2 KB)


pkgutils is missing