2014-03-02 31 views
-2

對不起,如果這個問題是愚蠢的簡單回答,但我已經到了一堵牆,我無法幫助擴展。Google Glassware Noob

基本上,我目前有我的應用程序偵聽語音,檢測並將檢測到的單詞輸出到卡上。我需要幫助:

A)爲卡分配一個ID以便它們可以被刪除 B)映射「Tap」手勢來調出一個菜單,以便可以刪除該卡。

當談到java時,我多多少少是一個noob,所以詳細的幫助非常感謝。

非常感謝您的幫助。

public class Notes 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(); 
     Log.i("Voice Input Results", voiceString); 

     //Create card 
     Card card = new Card(this); 
     card.setText(voiceString); 
     card.setFootnote("Notes"); 

     // Publish the card to the timeline 
     TimelineManager mTimelineManager = TimelineManager.from(this); 
     mTimelineManager.insert(card); 

     } 
    } 

回答

0

你可能想看看文檔here

下面是一些示例代碼,做你想做什麼:

// Tag used to identify the LiveCard in debugging logs. 
private static final String LIVE_CARD_TAG = "my_card"; 

// Cached instance of the LiveCard created by the publishCard() method. 
private LiveCard mLiveCard; 

private void publishCard(Context context) { 
if (mLiveCard == null) { 
    TimelineManager tm = TimelineManager.from(context); 
    mLiveCard = tm.createLiveCard(LIVE_CARD_TAG); 

    mLiveCard.setViews(new RemoteViews(context.getPackageName(), 
      R.layout.card_text)); 
    Intent intent = new Intent(context, EntryActivity.class); 
    mLiveCard.setAction(PendingIntent.getActivity(context, 0, 
      intent, 0)); 
    mLiveCard.publish(LiveCard.PublishMode.SILENT); 
} else { 
    // Card is already published. 
    return; 
} 
} 

private void unpublishCard(Context context) { 
    if (mLiveCard != null) { 
     mLiveCard.unpublish(); 
     mLiveCard = null; 
    } 
}