2014-09-30 36 views
0

如何在谷歌玻璃上顯示活卡?在開發活卡時,可能會有什麼特別需要照顧的問題。我已經創建了一個,但它不工作。這裏是我的服務代碼在Google眼鏡上創建活動卡片時出現問題。卡沒有顯示

public int onStartCommand(Intent intent, int flags, int startId) { 
    // TODO Auto-generated method stub 

    if (livecard == null) { 
     livecard = new LiveCard(this, "tag"); 

     // live card view 
     remote = new RemoteViews(getPackageName(), 
       com.example.livecardnew.R.layout.live_card); 
     livecard.setViews(remote); 

     // live card menu activity 
     Intent menuIntent = new Intent(this, MenuActivity.class); 
     menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 
       | Intent.FLAG_ACTIVITY_CLEAR_TASK); 

     // issue ths card when tapped 
     livecard.setAction(PendingIntent.getActivity(this, 100, menuIntent, 
       0)); 

     livecard.publish(LiveCard.PublishMode.REVEAL); 
    } 

    else { 
     livecard.navigate(); 
    } 
    return Service.START_STICKY; 
} 

AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.livecardnew" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="15" 
    android:targetSdkVersion="17" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" > 

    <!-- android:theme="@style/AppTheme" --> 

    <activity 
     android:name=".MenuActivity" 
     android:label="@string/app_name" > 

    </activity> 

    <service 
     android:name="com.example.livecardnew.MyService" 
     android:enabled="true" 
     android:exported="true" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.google.android.glass.action.VOICE_TRIGGER" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

     <meta-data 
      android:name="com.google.android.glass.VoiceTrigger" 
      android:resource="@xml/voice_trigger" /> 
    </service> 
</application> 

+1

有什麼錯誤?我們需要更多信息。謝謝! – pt2121 2014-09-30 15:21:51

+0

沒有錯誤,但卡沒有上傳到谷歌眼鏡上。 @EntryLevelDev – 2014-10-01 09:15:55

回答

0

這是無證的,但你必須添加一個意圖(使用的setAction方法),LiveCard否則將不會顯示... ...這是你做...所以我不是那樣。

您是否100%確定onStartCommand被調用,並且您的邏輯正在努力達到應設置並顯示LiveCard的代碼?得到有條不紊,並可能進行一些登錄。

+0

onStartCommand被第一次調用,當我們的應用程序開始或者當用戶滾動ayaya並選擇對應於我們卡的菜單時。如果m錯誤,請更正我。另外還有一件事是在創建一個服務類時創建一個意圖我傳遞MenuActivity.class(這是我的活動類)的參考,因爲我想附加菜單在我的活卡和一些視頻中,我已經看到了服務類的引用。那是什麼原因呢。 – 2014-10-01 09:13:41

+0

我也使用語音觸發器來通過語​​音命令來運行它。因此,只有可用的語音觸發器意味着只有通過語音命令才能觸發我們的應用程序的官方語音觸發器。或者我們可以在Voice_trigger.xml中使用我們的命令文件。 – 2014-10-01 09:19:43

+0

你應該關注一個單獨的問題。在這種情況下,您的問題在於LiveCard未顯示,因此請關注該消息並刪除外部因素,如語音觸發器以及您要構建的Intent的性質。聽起來像你認爲服務啓動,沒有看到它開始 - 使用日誌記錄來確保。 – straya 2014-10-01 12:48:13

相關問題