TeslaUnread API

TeslaUnread manages unread count badges for Nova Launcher Prime and WidgetLocker. Developers wishing to badge their apps with unread counts can use the TeslaUnread API to do so. Note that this is not for users of apps, only for app developers.

TeslaUnread's API uses a ContentProvider for you to insert your unread count to. This is done for security and accountability. Some developers may feel that the unread count is private meta data that should not be revealed to arbitrary apps. Using an unrpotected broadcast as some other unread count APIs do allows any app to intercept this. Using a custom permission to attempt to protect this broadcast frequently fails as Android does not properly handle custom permissions in third party applications. See Bug 65854. Additionally it's important for TeslaUnread to not be tricked by a misbehavior or malicious app that is reporting unread counts for apps aside from itself. Broadcasts do not allow the receiver to detect who sent the broadcast

Using TeslaUnread's content provider your app knows it is only sharing data with a trusted app and TeslaUnread can verify the UID of the app inserting an unread count against the desired package name.

That said, the API is very straightforward. If desired you may check for TeslaUnread (com.teslacoilsw.notifier) being installed*. The code below logs but ignores exceptions as any error in TeslaUnread is not worth crashing your app over. If you use a crash reporting library that allows remote loggging handled exceptions please do log these and contact me if the issue is on my end.

try {

    ContentValues cv = new ContentValues();

    cv.put("tag", "com.yourpackagename/com.youractivityname");

    cv.put("count", count);


} catch (IllegalArgumentException ex) {

    /* Fine, TeslaUnread is not installed. */

} catch (Exception ex) {

    /* Some other error, possibly because the format
       of the ContentValues are incorrect.

        Log but do not crash over this. */