Glass Card.toRemoteViews()返回null

时间:2013-12-09 01:38:12

标签: android google-glass google-gdk

使用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会简化很多事情。

1 个答案:

答案 0 :(得分:3)

目前尚未实施该方法;如果您想跟踪进度,可以在我们的问题跟踪器上关注issue 268

目前,您必须创建自己的布局XML并使用它来创建RemoteViews