Reputation: 49
I would like to send some data (string) from Android application to my Smartwatch extension.
I create an Intent in my Main Activity and send it using startService().
From that I understand, I have to override onStartCommand() in a class that extends ExtensionService.
My question is how my class that extends ControlExtension will be notify of this Intent ?
Thanks in advance
Upvotes: 0
Views: 256
Reputation: 1651
Your best option is to use a broadcast receiver. Register a receiver in your control and filter for the intent you send. (Instead of calling startService you should send your intent as a broadcast).
You can create and broadcast your intent with
Intent intent = new Intent("my.super.cool.intent.name");
sendBroadcast(intent)
and then filter with:
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("my.super.cool.intent.name");
Upvotes: 2