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 


Tooleap and B4A Part 3: Installation of Tooleap library and Application setup

The following library files need to be in your AdditionalLibs folder (these are all available in the B4A forum post here):

  • TooleapHelper (both jar/xml)
  • the latest tooleap sdk jar (current is tooleap-sdk-0.9.4.jar)

Before we start we need to make some manifest changes to the Application level.

These lines need to be added to your manifest editor:

For permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.GET_TASKS" />)

For Tooleap’s internal services:

<service android:name="com.tooleap.sdk.TooleapAppService"/>
<service android:name="com.tooleap.sdk.TooleapUIService"
                <action android:name="com.tooleap.sdk.BIND_UI_SERVICE" />
<receiver android:name="com.tooleap.sdk.TooleapReceiver">
               <action android:name="android.intent.action.PACKAGE_REPLACED"/>
               <data android:scheme="package"/>
               <action android:name="com.tooleap.sdk.TOOLEAP_ACTION"/>

Once you add these you are ready to start writing your Tooleap Activity/MiniApp.

Tooleap and B4A Part 2: Introduction to Tooleap

This is the first in a series of posts to explain how to use Tooleap with B4A.

You should sign up with their early access / beta program at: . They have very good documentation on site, and great support.

What you will need:

  • B4A 3.80 (may work with earlier version with some limitations)
  • Android SDK 2.2 (Version 8) and above.
  • the tooleap sdk jar (available here or from
  • the Tooleap Wrapper libraries I wrote available here
  • an API key from Tooleap developers Key Management page to publish/release an app

That is all.

You can make any activity into a TooleapActivity and it can run in either normal mode or in miniApp mode. You can have multiple instances of the same activity in miniApp mode.

The Tooleap Wrapper libraries contain 3 classes:

  • The TooleapManager class. This is used to manage the miniApps and can be used to add, remove or update the miniApps.
  • The TooleapMiniApp class. This is used to initialize and set the properties for the actual miniApp itself. This includes notification properties and app type etc.
  • The TooleapActivityHelper class. This is used with the Activity itself with some useful functions to find out whether the activity is in miniApp more or normal mode, or to find out its AppID.

Testing and Releasing a Tooleap app

You can test a Tooleap app without an API key. In order to do that you have to sign your apk with the debug certificate. In the B4A IDE go to Tools > Private Sign Key, and then select Use debug key at the bottom. You will be able to test the tooleap app, but remember you cannot release your app on the play store with a debug certificate.

For API keys, tooleap is still in early access mode, you first need to join the it using this link:

Once you join the program, you should be able to generate API keys. A tooleap API key is related to yourpackage name. To generate your API key go here:

Then, put in your package name and it will return an API key for you. This page also lists all your API keys.

Once you have your API key, you need to add this line in your manifest:

<meta-data android:name="com.tooleap.sdk.apiKey" android:value="YOUR-API-KEY-HERE" />)

Also to note some extra information:

  • The Tooleap SDK uses the internet permission. The miniApps have a searchbar (Google) bundled with them that requires this permission and allows users to search google from any miniApp. The SDK may also collect some analytics for further optimizations.
  • TooleapMiniApps at the moment at 80%x and Activity.Height-105dip. I am trying to find out a way to get the width and height after layout is measured, but it is not such a big issue. It is best not to use Dialogs/MsgBoxes with miniApps.


Tooleap and B4A Part 1: Introduction

I came across a pretty cool SDK called Tooleap. In their words:

Tooleap is an Android SDK which brings your app to the forefront
of a user’s device screen with a floating (always-on-top) UI,
thus creating a unique multitasking experience and increasing
your app’s availability and usability.

From what I understand Tooleap functionality consists of two parts.

1. A rich floating notification. This can notify the user of new data, or just be available to interact with from anywhere.

2. MiniApps, which are a slide-out window providing the same functionality of a usual activity, without losing context of the previous activity.

After reading their SDK I didnt think we would be able to use it in B4A since it required us to subclass Activity which we never had been able to do before, but Erel gave us a lifeline and now we are able to subclass Activity, thus being able to use this SDK.

I wrote some thin Java wrappers to get the functionality into B4A.

Dim TooleapManager1 As MSTooleapManager
Dim TooleapMiniApp1 As MSTooleapMiniApp
Dim TooleapActHlper As MSTooleapActivityHelper