The wrong screen is displayed after one of my apps calls another

24 Views Asked by At

My app (app A) has options to send location data either to

  • Google Maps, or to
  • an app (app B) that I have written to display topographical maps

The code in app A for calling the two apps is essentially identical

btnGoogleMap.setOnClickListener {
    var uriString =
        "geo:0,0?q=$selectedPoiLatitude,$selectedPoiLongitude&z=11"
    var gmmIntentUri =
        Uri.parse(uriString)
    val googleMapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
    googleMapIntent.setPackage("com.google.android.apps.maps")
    startActivity(googleMapIntent)
}

btnMyMap.setOnClickListener() {
    var mmUriString = "latlong:$selectedPoiLatitude,$selectedPoiLongitude"
    var mmIntentUri = Uri.parse(mmUriString)
    val mmIntent = Intent("com.prepbgg.mymap.action.latlong",mmIntentUri)
    mmIntent.setPackage("com.prepbgg.mymap")
    startActivity(mmIntent)
}

After using the option to call app B (mymap), the task switcher shows the same thumbnail (of the map displayed in app B) for app A as well as for app B. If I then use the task switcher to reopen app A it opens with the map from app B displayed. The same happens if I reopen app A from the Home screen or the app drawer. I have to use the back button to get app A to display its own screen.

If I call Google Maps from app A, the task switcher shows different thumbnails as I would expect: a thumbnail of Google Maps for Google Maps and a thumbnail of app A's screen for app A and that is what I see if I reopen app A.

How can I get the same behaviour when calling app B as I get when calling Google Maps?

0

There are 0 best solutions below