【问题标题】:Vibrate smartwatch振动智能手表
【发布时间】:2014-07-08 06:43:58
【问题描述】:

我想通过在智能手表上振动来确认我在智能手机上执行的操作(例如发送电子邮件时)。

在我的 MainActivity(发送电子邮件时)我有:

Intent serviceIntent = new Intent(this, HelloExtensionService.class);
serviceIntent.setAction(HelloExtensionService.INTENT_ACTION_SEND);
startService(serviceIntent);

我通过一个示例了解我必须在扩展 ExtensionService 的类中覆盖 onStartCommand :

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
     Intent i = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
 i.setPackage("com.example.hellosmartwatch");
 sendBroadcast(i);
}

@Override
public ControlExtension createControlExtension(String hostAppPackageName) {
        boolean advancedFeaturesSupported = DeviceInfoHelper.isSmartWatch2ApiAndScreenDetected(this, hostAppPackageName);
        if (advancedFeaturesSupported) {
            return new Vibrator(this,hostAppPackageName, new Handler());
        } else {
            return null;
        }
    }

我知道我必须使用 ControlExtension,在我的例子中是 Vibrator.class,所以我重写了 onStart() 方法:

@Override
public void onStart() {
startVibrator(500, 300, 2);
}

但它不起作用。我想念的或我不明白的有一些有用的东西。

【问题讨论】:

    标签: android sony sony-smartwatch


    【解决方案1】:

    我想知道您是否想要使用通知扩展而不是控制扩展。这将为您振动手表并快速记录以前的事件。如果您需要此类扩展的示例,我会推荐 Sony Add-On SDK 中的 HelloNotification 示例。否则,如果您使用 Control 扩展程序,则必须在 SmartWatch 上启动应用程序运行振动命令,然后停止应用程序。这听起来对你有用吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多