how to show a screen if sony smartwatch is locked

2019-08-27 03:40发布

问题:

How to show a screen in sony smartwatch 2 when screen is locked like we does with a call application. even if the screen is locked when we receive a call it shows upfront. I am able to show this when my app is open through a control api. but when my app is not open and some event happen in my mobile app i have to show the same in smart watch as well. I think we can do this with tunnel service but i dont know how. Pls help

回答1:

To start a ControlExtension on SmartWatch2, there is a startRequest command, which can be sent this way:

protected void startRequest() {
    Intent intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
    sendToHostApp(intent);
}

where

protected void sendToHostApp(final Intent intent) {
    ExtensionUtils.sendToHostApp(mContext, mHostAppPackageName, intent);
}
  • mContext is the Context of your activity or service, from where you are sending the command
  • mHostAppPackageName is the name of the invoked device host application, in this case for SmartWatch2: "com.sonymobile.smartconnect.smartwatch2"

This command will start and show the ControlExtension, which is registered in your application.