Timo
Timo

Reputation: 165

Start Layout on Smartwatch 2 from Android App

I scanned through the SW2 SDK examples and read through the supplied documentation but have problems adjusting those to fit the needs of my application.

Currently I try to integrate the SW2 support to my existing android application. Here is what I try to achieve in detail:

  1. When the user clicks the start button within the phone application the SW2 should awake and my smartwatch layout should be brought to the front.

  2. After this point the SW2 should not go back to sleep until the phone app is closed.

  3. The phone application updates the textview of the SW2 layout every 10seconds (for example) or when it’s needed.

I first started with integrating notifications where data was sent to the SW2 via intents. Obviously this was not exactly what I wanted to achieve because I do not want to stack notifications but always show the current information.

Now I would like to do the same based on the SW2 SDK layout example. But I do not know how to do so in order to fulfill point 1-3. Maybe you could provide me with some sample code which shows how the service, receiver, control, etc. classes have to be set up and how to bring the layout to the SW2 front when the button is clicked & how to trigger the textview updates etc. from my main activity.

Upvotes: 1

Views: 123

Answers (1)

mldeveloper
mldeveloper

Reputation: 2238

Sounds like you should be using a Control extension if you want to draw a TextView to the screen. The HelloLayouts example would be a good starting point.

Regarding your questions:

  1. Take a look at the ControlExtension.startRequest() method. You can call this from your phone app to start your SW2 app.

  2. To keep the backlight of the SW2 on, you can use ControlExtension.setScreenState(Control.Intents.SCREEN_STATE_ON)

  3. This can be done by using a timer and calling showLayout() with the text you want to update every 10 seconds.

Upvotes: 1

Related Questions