Question

I'm developing a RSS smart extension app using the Notification API. I would like to know how to get the active/inactive status of my smart extension (the first checkbox when clicking on my RSS smart extension in the SmartWatch app).

The NotificationAPI sample uses an extra Checkbox preference to start or not a service downloading data generating notifications, but I don't want to force the user to go into a sub menu and activate the download of data. If the user activates my RSS smart extension, he already expects the extension to notify him if there's some new items into the RSS.

There's a callback to know when my smart extension is correctly added to liveware/smartwatch apps (onRegisterResult), but I didn't find the callback to know if the smart extension is actually active or not.

Thanks in advance!

Was it helpful?

Solution

The SampleNotificationExtension of the Smart Extension SDK has been provided to give some examples on:

  • how to add/update/remove/read data to/from the Notification database that resides in the Liveware Manager application (which is the hub of the Smart Extension API) through a content provider

  • how to respond to the event that the user opens a Notification on the SmartWatch and e.g. presses the action button

In the example extension, there is a service that is feeding the Notification database each 10 seconds, which is then shown on the SmartWatch device. The on/off setting in the preference activity is just for starting and stopping the loop that feeds the database.

Ok.

So I guess you want to subscribe to RSS feeds, and when new posts arrive, you want them to be propagated to the SmartWatch. You probably need start a service, like in the example, and you probably should have the service running as long as the watch is connected to the phone. This you can specify here:

@Override
protected boolean keepRunningWhenConnected() {
    return true;
}

If you use the SmartExtension utility classes, your extension will automagically be registered and your service will be started. In the sample extension, after the extension has been registered, a check is done to see if the user has activated the extension via the preferences.

@Override
public void onRegisterResult(boolean result) {
    /.../
    boolean isActive = prefs.getBoolean(
            getString(R.string.preference_key_is_active), false);
    if (isActive) {
        startAddData();
    }
}

You could keep this if you want, but it is not required. As stated before, its just for starting and stopping the data feeding. Anyways, you could start a RSS check after registration.

If the user activates my RSS smart extension, he already expects the extension to notify him if there's some new items into the RSS.

When the service starts, you can check a delta between what is in the notification database, and what is fed from the RSS feed.

WELL, a long answer, hope it helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top