gpt4 book ai didi

google-glass - 未插入 Google Glass Live Card

转载 作者:行者123 更新时间:2023-12-01 01:04:16 25 4
gpt4 key购买 nike

玻璃 GDK 在这里。尝试使用来自服务的远程 View 插入 livecard。我正在通过语音调用启动服务。语音命令有效,但是我的服务似乎没有启动(日志中没有条目)。服务在 android list 中。下面是代码:

public class PatientLiveCardService extends Service {

private static final String LIVE_CARD_ID = "timer";


@Override
public void onCreate() {
Log.warn("oncreate");
super.onCreate();
}

@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
publishCard(this);

return START_STICKY;
}

@Override
public void onDestroy() {
unpublishCard(this);
super.onDestroy();
}



private void publishCard(Context context) {
Log.info("inserting live card");
if (mLiveCard == null) {
String cardId = "my_card";
TimelineManager tm = TimelineManager.from(context);
mLiveCard = tm.getLiveCard(cardId);

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

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

}

这是 AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />

<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO" >
</uses-permission>

<application
android:name="com.myApp"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.myApp.MyActivity"
android:label="@string/app_name"
android:screenOrientation="landscape" >
</activity>

<service android:name="com.myApp.services.MyService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>

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

</application>

最佳答案

这是XE11的一个bug:语音识别完成后服务没有启动。

作为解决方法,您可以让语音触发器启动 Activity哪一个:

  • 处理 onResume 中识别的语音.
  • 处理完语音后,开始您的 ServicestartService .
  • 电话 finish跳转至已发布 LiveCard .
  • 关于google-glass - 未插入 Google Glass Live Card,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20100120/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com