使用Google Glass GDK,我正在尝试整理一个显示/更新现场卡的简单应用。在我的服务中,我有以下方法:
private void publishCard(Context context) {
Card updatedCard = new Card(context);
updatedCard.setText("Foo");
updatedCard.setInfo("Bar");
RemoteViews cardViews = updatedCard.toRemoteViews();
if (cardViews == null)
Log.e(TAG, "Appears to happen every time!")
// Then do some other stuff that fails because of a null RemoteViews
}
正如您在上面所看到的,每次检查似乎都会失败。知道为什么会这样吗?
我的想法是,我正在调用此函数并将服务作为上下文而非活动传递,也许您不应该这样做?如果是这样的话,你怎么能更新Live Card?我能够从XML构建RemoteViews,但是能够使用Card会简化很多事情。