Launch an app temporarily

Hello all

My problem today is I want to launch an second app from my main AI app only for few seconds and then come back to my main app

si i tried this:
image

So the second app is launch, but my main app doesn't come back on screen...
is someone has any idea to solve this ?

My first idea is that's Trojan activity and your phone will close it down.

What can the second App do that you can't include in your main App?

Who makes the decision, when, how and through which action, to bring the app back to the foreground?

What exactly is your second app doing?

Taifun

my second app is a GPS app which ring on radar proximity.

the clock in my first app decides it

...

sorry Anke, i don't understant your question:

my Main app want to start an second app and after few seconds automatiquely comme back to foreground

I found a solution to make it works, but it's not very clean: it seems the problem is my first app can't lanch itself...so it lanch a third app and this one lanch main one...

As a rough idea, this can be achieved using Activity Starter (if not, then Intents).

is this an App Inventor app?
why don't you just include that functionality directly in your main app?

Taifun

no it is a standard GPS app...

how do you do this ?

How did you do it in the timer event?

Show your blocks (of the timer event).

Try these 2 simple apps:

Install both apps, open app1, click button "Open App2", app2 should be opened, wait 10 sec and app1 should be opened (come to the foreground) again.


Tested on Android 13.


EDIT: APKs removed.

Can confirm, doesn't work on Android 14.

True, I checked it on Android 14. I have no idea why it only works on Android < 14 and I seem to be not the only one when searching the web for explanations/solutions. :woman_shrugging:

There were some method deprecation in package manager on Android 14.

android.content.pm.PackageManager$NameNotFoundException: appinventor.ai_bodymindpower.app2
at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:568)
at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:551)
at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:545)
at com.sunny.PkgUtils.PkgUtils.IsAppInstalled(Unknown Source:7)
at com.sunny.PkgUtils.PkgUtils.LaunchApp(Unknown Source:0)

Try these small apps:

Both APKs do not have the following high-risk permissions in the Manifest (which Google most likely does not allow):

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

Tested on Android 14 (Pixel 7 Pro).

...but these lines:

    <queries>
        <package android:name="appinventor.ai_bodymindpower.app1"/>
        <package android:name="appinventor.ai_bodymindpower.app2"/>
    </queries>