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):

AddActivityText(test,
<intent-filter>
<action android:name="com.tooleap.sdk.TOOLEAP_SHOW"/>
</intent-filter>
)
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"
Else
    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 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s