FORUMS

[GUIDE] Apex Launcher Notifications API

268 posts
Thanks Meter: 2,728
 
By dennisxl, Senior Member on 10th October 2012, 06:20 PM
Post Reply Email Thread
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:

HTML Code:
<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 Code:
<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.
The Following 10 Users Say Thank You to dennisxl For This Useful Post: [ View ] Gift dennisxl Ad-Free
11th October 2012, 05:40 AM |#2  
lost_'s Avatar
Senior Member
Flag DC
Thanks Meter: 490
 
More
Slightly off-topic... would be nice if Apex Pro can provide configurable badge colors. Holo Plus provides background, ring, and text color options.

Also, as some users don't ever use certain features, extra features like the notifier could be shipped out as plugins to keep the core Apex quick and slim.
11th October 2012, 06:26 PM |#3  
dennisxl's Avatar
OP Senior Member
Thanks Meter: 2,728
 
More
Quote:
Originally Posted by lost_

Slightly off-topic... would be nice if Apex Pro can provide configurable badge colors. Holo Plus provides background, ring, and text color options.

Also, as some users don't ever use certain features, extra features like the notifier could be shipped out as plugins to keep the core Apex quick and slim.

Apex already supports badge style customizations through themes. Here's a link to the theme tutorial.

Yes, it is possible to ship the notifiers as a separate plugin app, both to keep the core app slim and to better manage permissions. However, some people actually prefer to have the functionality built-in so they do not have to install another app. It's a trade-off.
The Following 2 Users Say Thank You to dennisxl For This Useful Post: [ View ] Gift dennisxl Ad-Free
29th October 2012, 09:01 AM |#4  
itzik2sh's Avatar
Senior Member
Thanks Meter: 738
 
Donate to Me
More
Can Apex launcher support GO notification EX app or offer an alternative ?
I know a few people that stay on the GO launcher and not move to Apex launcher, just because of this feature...
12th December 2012, 11:40 AM |#5  
Member
Thanks Meter: 18
 
More
I'm not a developer, but would this API allow for a Tasker-plugin to display any numerical Tasker-variable as the "unread" count on any dock icon? Or is it limited to that each app can only display "their own" count; i.e., the K9-devs would need to include this in order to get unread count on a K9 dock icon?
15th January 2013, 02:41 AM |#6  
dennisxl's Avatar
OP Senior Member
Thanks Meter: 2,728
 
More
Quote:
Originally Posted by trollsperm

I'm not a developer, but would this API allow for a Tasker-plugin to display any numerical Tasker-variable as the "unread" count on any dock icon? Or is it limited to that each app can only display "their own" count; i.e., the K9-devs would need to include this in order to get unread count on a K9 dock icon?

Since there is no generic way to retrieve unread counts from different apps, each app developer need to use this API to display the count on the desired app icon.
15th March 2013, 03:07 PM |#7  
The_MutenRoshi's Avatar
Senior Member
Flag Faro
Thanks Meter: 13
 
More
I have the pro version and everthing well done on settings, I have the sms and phone notification icon working, but on Gmail that I installed from play store ( not from Gaaps or built in phone, had to install it) the notification is not working... I have unread mails and do not show up...

anyone knows why?
21st May 2013, 07:09 PM |#8  
koko115's Avatar
Senior Member
Thanks Meter: 335
 
Donate to Me
More
For me to. I have pro apex, and notify dont show on stock email on galaxy s3, please tell me why ?
21st May 2013, 10:19 PM |#9  
dennisxl's Avatar
OP Senior Member
Thanks Meter: 2,728
 
More
Quote:
Originally Posted by koko115

For me to. I have pro apex, and notify dont show on stock email on galaxy s3, please tell me why ?

You need to install the Apex Notifier extension app and turn on Samsung Email there.
21st May 2013, 10:57 PM |#10  
koko115's Avatar
Senior Member
Thanks Meter: 335
 
Donate to Me
More
Of corse i install this, and dont show notifi on stock app email icon.
21st May 2013, 11:18 PM |#11  
dennisxl's Avatar
OP Senior Member
Thanks Meter: 2,728
 
More
Quote:
Originally Posted by koko115

Of corse i install this, and dont show notifi on stock app email icon.

Can you check three things?
1. Did you see unread count on the Email icon in the TouchWiz Launcher?
2. Is the Email app selected if you go to Notification settings in Apex Launcher?
3. Did you use the "Samsung Email" or "Email" in Apex Notifier? If one does not work, have you tried the other?

BTW, this is not the right thread for this discussion. There is a dedicated Apex Notifier thread here on XDA.
Post Reply Subscribe to Thread

Tags
apex, apex-launcher, api, launcher, notifications

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes