java如何从smartwatch启动活动或服务
我曾尝试使用wearablelistener服务,但它们似乎已被弃用
这是我目前的代码:
public void lockdevice(View view) {
Intent intent = new Intent();
intent.setClass(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
RemoteIntent.startRemoteActivity(this, intent,null);
}
它会创建一个异常:
Only 安卓.intent.action.VIEW action is currently supported for starting a remote activity
但是一个视图操作对我没有多大帮助。还有其他方法吗
# 1 楼答案
我是通过以下方式实现的。在你的掌上电脑
AndroidManifest.xml
在你的Wear应用程序中:
# 2 楼答案
WearableListenerService
并没有遭到反对。对于手持设备上的Service
,它仍然是建议从链接的可穿戴设备启动的超类。一旦Service
启动,如果需要的话,可以从那里轻松启动Activity
这里有很好的记录:https://developer.android.com/training/wearables/data-layer/events.html