All posts
Android

Multi-Window Simple Examples: Part 3 – Launching another app

Mateusz Budzar

Mateusz Budzar

Introduction

This is the last part of the series about Multi-Window simple examples. And it’s indeed very simple. This time, we will focus on launching another application from our app. The point is that this new application will not replace our app on the screen but will be displayed next to it or below it. There is only one condition to meet – we have to be in split-screen mode.

Just one more flag

To simplify this example to the maximum we explicitly tell MultiWindowCatch app to open MultiWindowDropAdjacent app after clicking on some Pokemon.

The result of sending that kind of Intent is to open the Launcher Activity of the app as we pointed out by passing the full package name to PackageManager.getLaunchIntentForPackage() method that will create this Intent for us. You can, of course, use different, more sophisticated way to open another app and you can read about it in Allowing Other Apps to Start Your Activity.

Take a look at flags that we pass. Especially at Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT. By passing this flag, we just say to Android system: “If it’s possible, please open this app next to me or below me, but if it’s not, just show it instead of me.”

The last thing that left is to get that Intent in MultiWindowDropAdjacent app and show selected Pokémon.

As you can see we simply get the Extras, set current Pokémon id, wait for Activity.onStart() method and show the image.

Summary

Launching another app in Multi-Window mode comes down to adding one more flag to Intent object. We are able to start another app in a couple of ways and it’s up to us how we will handle it.

<< Part 2 – Drag and drop

The post is created by Droids On Roids Team Member.
We would love to take care of your project.

Hire US!

Leave comment

  • pratham kesarkar

    Thanks