Tooleap and B4A Part 5: Launching a MiniApp

You can launch your miniApp from another activity or service. To manage your miniApps you will need to use the MSTooleapManager object. This object allows you to add/remove or find your miniApps.

To create and set up a particular miniApp you will need to use the MSTooleapMiniApp object.

Lets see how to create and start an activity in miniApp mode and also to set up its notification object.

We start off by creating an intent to our activity. This is in the format of “<packagename>/.<activityname>”. (There were probably easier ways to do this but I chose this to remain flexible)

 Dim i1 As Intent

Then we set up our miniApp object:

TooleapMiniApp1.ContentTitle = "A sample Title"
TooleapMiniApp1.ContentText = "content TExt"
TooleapMiniApp1.NotificationText = "Notification Text!"
TooleapMiniApp1.NotificationBadgeNumber = 3
TooleapMiniApp1.bubbleBackgroundColor = Colors.Transparent

Simple stuff, just setting up the Header/Titles.

Now to actually start the floating notification we need to add the miniApp using the manager.

appID = TooleapManager1.addMiniApp(TooleapMiniApp1)

That is it! That will start a notification, and when you click on the notification, it will launch your activity in miniApp mode.
You can customise the miniApp more using the object, and can manage them using the manager object. You can remove all miniApps or remove particular ones, and list them all etc.

Tooleap and B4A Part 4: Creating a Tooleap Activity in B4A

Once you create a Tooleap Activity, it can be used in normal mode or in miniApp mode (but only one at a time).

To set up your activity as a Tooleap Activity, you need to follow some steps. Firstly, we will change the activity type by using the following activity attribute (in your activity attributes section).

#extends: com.tooleap.sdk.TooleapActivities.Activity

Then in your manifest, you need to add the following lines (remember to replace with your activity name):

<action android:name="com.tooleap.sdk.TOOLEAP_SHOW"/>
SetActivityAttribute(test, android:theme, "@android:style/Theme.Translucent")
SetActivityAttribute(test, android:launchMode, "singleInstance")
SetActivityAttribute(test, android:taskAffinity, ".tooleap")

That is all the preparation that is required.

Now remember in miniApp mode the size of the Activity will be different (80%x, 100%y-105dip). In order to find out if the activity is in normal or miniApp mode you can use the MSTooleapActivityHelper object:

Dim TA As MSTooleapActivityHelper

If TA.isStartedByTooleap Then
    lbl.Text = "Started by Tooleap"
    lbl.Text = "Started in normal mode"
End If

To get the current activity’s app id (each miniApp must have its own ID)

Dim appID As Long = TA.getCurrentActivityTooleapAppId