Apex Launcher now offers a public API that lets any application display notification badges on specific icons on the home screen. This is a useful developer feature that allows integration from other applications. For instance, any third-party Email app may notify users of the number of unread emails in Apex Launcher.
To use the API, the Apex Launcher app must be at version 1.3.2 or higher. This feature only works in the pro version and the user needs to enable external notifiers in advanced settings.
Preparation
To use the notifications API, your application must request the proper permission, com.anddoes.launcher.permission.UPDATE_COUNT. Please request this permission in your AndroidManifest.xml file by declaring a <uses-permission> element as a child of <manifest>, as follows:
Updating Notification Counts
Whenever your app needs to update the notification count, send a broadcast intent to Apex Launcher with the following information:
Here’s an example:
Generally, there are two situations in which you want to update Apex Launcher with notifications. First, you may push new data to Apex when something changed in your application. For example, you can increase the unread count with the above broadcast intent when there is an incoming email. Second, Apex Launcher may request updates from your application upon certain events. For example, when Apex is started, it needs to poll the latest data from your application. To respond to such requests, you need to include a broadcast receiver in your application.
Responding to Update Requests
When Apex Launcher needs to request data from external notifiers, it sends a broadcast with the UPDATE_COUNTER action. To respond to such requests, you may declare a broadcast receiver like this in your manifest file:
When you receive this intent in your broadcast receiver, just use the code in the previous section to notify Apex of the latest data.
Sample App
You can find a sample app that makes use of the new API here. Please add the app icon to your desktop to see the notification badge.
I hope you find this API useful and I'm looking forward to seeing some nice app integration with Apex Launcher.
To use the API, the Apex Launcher app must be at version 1.3.2 or higher. This feature only works in the pro version and the user needs to enable external notifiers in advanced settings.
Preparation
To use the notifications API, your application must request the proper permission, com.anddoes.launcher.permission.UPDATE_COUNT. Please request this permission in your AndroidManifest.xml file by declaring a <uses-permission> element as a child of <manifest>, as follows:
HTML:
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT" />
Updating Notification Counts
Whenever your app needs to update the notification count, send a broadcast intent to Apex Launcher with the following information:
- The COUNTER_CHANGED action;
- Target component (package and class names) identifying the icon where the notification badge appears;
- The unread count for the notification.
Here’s an example:
Code:
final String ACTION_COUNTER_CHANGED = "com.anddoes.launcher.COUNTER_CHANGED";
final String EXTRA_NOTIFY_PACKAGE = "package";
final String EXTRA_NOTIFY_CLASS = "class";
final String EXTRA_NOTIFY_COUNT = "count";
final String packageName = getPackageName();
final String className = packageName + ".MainActivity";
Intent intent = new Intent(ACTION_COUNTER_CHANGED);
intent.putExtra(EXTRA_NOTIFY_PACKAGE, packageName);
intent.putExtra(EXTRA_NOTIFY_CLASS, className);
intent.putExtra(EXTRA_NOTIFY_COUNT, getCount());
sendBroadcast(intent);
Generally, there are two situations in which you want to update Apex Launcher with notifications. First, you may push new data to Apex when something changed in your application. For example, you can increase the unread count with the above broadcast intent when there is an incoming email. Second, Apex Launcher may request updates from your application upon certain events. For example, when Apex is started, it needs to poll the latest data from your application. To respond to such requests, you need to include a broadcast receiver in your application.
Responding to Update Requests
When Apex Launcher needs to request data from external notifiers, it sends a broadcast with the UPDATE_COUNTER action. To respond to such requests, you may declare a broadcast receiver like this in your manifest file:
HTML:
<receiver android:name=".UpdateCountReceiver">
<intent-filter>
<action android:name="com.anddoes.launcher.UPDATE_COUNTER" />
</intent-filter>
</receiver>
When you receive this intent in your broadcast receiver, just use the code in the previous section to notify Apex of the latest data.
Code:
final String ACTION_UPDATE_COUNTER = "com.anddoes.launcher.UPDATE_COUNTER";
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null && ACTION_UPDATE_COUNTER.equals(intent.getAction())) {
// update Apex with latest data
update();
}
return;
}
Sample App
You can find a sample app that makes use of the new API here. Please add the app icon to your desktop to see the notification badge.
I hope you find this API useful and I'm looking forward to seeing some nice app integration with Apex Launcher.