Question

I'd like to write an app that monitors incoming SMS and notify me on the watch if the content of SMS contains a predefined text (e.g. "go home").

I know I can use the notification API to add an event. It will vibrate and show a small app icon on the watch. What if I want to use control API to flash LED and show the whole text and an image on the watch when it receives the SMS, how should I do?

It's very similar to the "Call handling" add-on. Can Sony open the source of "Call handling" for reference?

Was it helpful?

Solution

I think you have two options. Either, as you say, 1) implement an extension that uses both the notification API and the control API. Or 2) just implement a control extension.

For 1), you could add a custom action that starts your control extension using the START_REQUEST intent below. See the doAction1 method in the SampleNotificationExtension code. This would mean that a standard notification will be shown on the watch, then you will be able to present a custom view to the user, if the user clicks the custom action button.

And for 2), implement your functionality completely as a control extension and request for it to be started when you get the SMSs that is found by your filter. Drawback is that you need to present the SMS text yourself, which in case 1) is done by the framework for you.

START_REQUEST-intent example:

Intent intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "your.package.name");
intent.setPackage(hostAppPackageName);
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top