Android Question How to launch another app to run in parallel?

RobertK

Member
Licensed User
When I launch one of my apps from another using the following code, the second app replaces the first. They have only one entry in the list of recent apps, which shows only the first app. The user cannot kill one app without killing the other and cannot switch between them.

Launching a second app of my own:
Dim MyIntent As Intent
MyIntent.Initialize(MyIntent.ACTION_MAIN, "")
MyIntent.SetComponent("my.second.app/.main")
StartActivity(MyIntent)

However, when I launch Google Earth from my app using the following code, the two do run in parallel. They have separate entries in the list of recent apps. The user can kill Google Earth without killing my app and vice-versa. The user can switch freely between my app and Google Earth. This is the behavior I am looking for.

Launching Google Earth:
Dim MyIntent As Intent
MyIntent.Initialize(MyIntent.ACTION_VIEW, "")
MyIntent.SetType("application/vnd.google-earth.kml+xml")
StartActivity(MyIntent)

What is correct way to achieve the desired behaviour with two of my own apps?
 

netsistemas

Active Member
Licensed User
Longtime User
look at this thread


only do this:

B4X:
  Try
    Dim Intent1 As Intent
    Dim pm As PackageManager
        'Intent1 = pm.GetApplicationIntent ("com.whatsapp.w4b")  'whastupo bussines    - 'com.whatsapp for normal whatsup
        Intent1 = pm.GetApplicationIntent ("packane.name.here")
    StartActivity (Intent1)
      Catch
      ToastMessageShow ("Failed to launch app!  Is it installed?", True)
  End Try

No more is neccesary
 
Upvote 0
Top