Outbound data and message payloads transmissions will be retried until success or a timeout occurs. You can observe terminal status changes with intents.
HelloDropdownReceiver
publicstaticfinalString SOMEWEAR_MESSAGE_OUTBOUND ="com.somewearlabs.tak.message.OUTBOUND";override fun onReceive(context: Context, intent: Intent) {switch (action) {caseHelloWorldDropDownReceiver.SOMEWEAR_MESSAGE_OUTBOUND: {String status =intent.getStringExtra("status");int parcelId =intent.getIntExtra("parcelId",0);if (status.equals("Delivered")) {Log.d(TAG,"onReceive: did send Somewear message; parcelId="+ parcelId); } elseif (status.equals("Error") {Log.d(TAG,"onReceive: Somewear message did timeout; parcelId="+ parcelId); }break; } }}
Inbound
A third party plugin can listen for inbound workspace messages as well.
During development, this must first be enabled in the Somewear plugin debug menu. To show the debug menu go to Settings > Long press on Send Logs. Then toggle Broadcast inbound messages.
Once the debug option is enabled, you can listen for inbound messages by registering a BroadcastReceiver. Your plugin’s DropDownReceiver implements BroadcastReceiver already. Here’s a modified version of the helloworld sample:
HelloWorldMapComponent
publicstaticfinalString SOMEWEAR_MESSAGE_INBOUND ="com.somewearlabs.tak.message.INBOUND";override fun onCreate(pluginContext: Context, intent: Intent, mapView: MapView) {DocumentedIntentFilter ddFilter =newDocumentedIntentFilter();ddFilter.addAction(HelloWorldDropDownReceiver.SHOW_HELLO_WORLD,"Show the Hello World drop-down");ddFilter.addAction(HelloWorldDropDownReceiver.SOMEWEAR_MESSAGE_INBOUND,"Observe inbound Somewear payloads");this.registerDropDownReceiver(this.dropDown, ddFilter);}
You can send/receive generic data payloads as well.
Outbound
byte[] data ="Just some bytes".getBytes(StandardCharsets.UTF_8);Intent intent =newIntent("com.somewearlabs.tak.data.SEND");intent.putExtra("data", data);AtakBroadcast.getInstance().sendBroadcast(intent);
Inbound
Unlike inbound message payloads, you don’t have to change any settings in the Somewear plugin to listen for data payloads.
HelloWorldMapComponent
publicstaticfinalString SOMEWEAR_DATA_INBOUND ="com.somewearlabs.tak.data.INBOUND";override fun onCreate(pluginContext: Context, intent: Intent, mapView: MapView) {DocumentedIntentFilter ddFilter =newDocumentedIntentFilter();ddFilter.addAction(HelloWorldDropDownReceiver.SHOW_HELLO_WORLD,"Show the Hello World drop-down");// Observe inbound message payloadsddFilter.addAction(HelloWorldDropDownReceiver.SOMEWEAR_MESSAGE_INBOUND,"Observe inbound Somewear payloads");// Observe inbound data payloadsddFilter.addAction(HelloWorldDropDownReceiver.SOMEWEAR_DATA_INBOUND,"Observe inbound Somewear data payloads");this.registerDropDownReceiver(this.dropDown, ddFilter);}