【问题标题】:Card won't publish/Glassware stops卡不会发布/玻璃器皿停止
【发布时间】:2014-02-10 04:00:43
【问题描述】:

我正在尝试制作我的第一个 Google Glass 应用程序(如果你算上 Hello World 项目,第二个应用程序 :)),需要一些帮助。我创建了第一部分,结果还不错(该应用程序同时显示在语音命令列表和“启动器”中,我可以运行它/与它交谈),所以我很高兴能走到这一步!我的问题是,如何将卡片发布到时间线?:

package com.test.glass.glassnotes;

import java.util.ArrayList;

import com.google.android.glass.app.Card;
import android.app.Activity;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.view.View;


public class MainActivity extends Activity {

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get voice input results
    ArrayList<String> voiceResults = getIntent().getExtras()
            .getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
    String voiceString = "";
    for(String str:voiceResults){
        voiceString = voiceString + " " + str;
    }
    voiceString = voiceString.trim();

            //Create card
            Card card1 = new Card(this);
            card1.setText(voiceString);
            card1.setFootnote("GlassNotes");
            View card1View = card1.toView();

            // Display card
            setContentView(card1View);
    }
}

我在 Java 方面有点菜鸟,所以我边走边学...

另外,值得注意的是,我正在尝试创建的应用程序是一个简单的记事本应用程序,用户可以在其中说出文本,并将一张新卡片添加到时间线以供将来参考,其中包含语音文本。我正在使用 GDK Sneak Peek 在 Eclipse/ADT 中执行此操作。

提前感谢您的所有帮助!

【问题讨论】:

    标签: android google-glass google-gdk


    【解决方案1】:

    要将已发布的卡片添加到时间线,您需要使用https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/TimelineManager 中记录的 GDK TimelineManager API

    例如:

    mTimelineManager = TimelineManager.from(this);
    mTimelineManager.insert(card);
    

    请注意,使用 Card 创建的时间轴上的卡片(静态卡片)仅保留 7 天 (https://developers.google.com/glass/design/ui/static-cards)。

    【讨论】:

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