Using the same activity in multiple mini apps

Tooleap SDK allows you to use the same Tooleap activity in multiple mini apps – for example, you might have an activity that displays a conversation with someone, and you want to create several mini-apps that each one of them uses this activity to show a conversation with a different person.

Tooleap creates only one instance of a given activity class, even if it’s being used in multiple mini-apps, but also provides means to tell which mini-app is currently using this activity, as we’ll see next.

Here’s an example of a creation of 2 different mini-apps that use the same activity class:

Each call to addMiniApp, adds a new mini app and outputs a newly created app id.

Notice that you can also provide different “extra data” inside each intent you create, so that the data will be accessible later on inside the activity onNewIntent(Intent intent) method.

 

Doing different things for different mini-apps using the same activity

Inside your Tooleap Activity class you can distinguish between the different mini apps in several ways:

  1. Create different extra data for each mini app intent, and retrieve that data in the activity’s onNewIntent(Intent intent) method.
  2. Use getTooleapAppId() method.

If we’ll go back to the example of a conversation activity, how can you tell which mini-app is currently using this activity?

You can save the different app ids returned from the addMiniApp, and use them to later distinguish between the different conversation (e,g., appId1 and appId2).

For example: