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

Hi is it possible to integrate a second application to an application created by me?
thank you

Depending on what you mean by 'integrate', you probably can use the Activity Starter. See Using the Activity Starter

This video may be useful for you @Gianluca_Giambri :-

Thanku

2 Likes

thanks for the reply but the other application is not done with mit appinventor

I would like to integrate to my application "zettle"

Gianluca, se non ti va bene usare Activity Starter devi spiegarti meglio.

How about answering @SteveJG's question?

Salutations
to integrate I mean click on a button and open the application "zettle" thanks

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 dat=vnd.youtube:nAPk9ycCbfc cmp=com.google.android.youtube/.PlayerActivity }

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

How to inspect the log see also here

Taifun

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.)

grafik

2 Likes

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 ?