[英]How to publish live card in Google Glass before unpublishing the previous instance of the livecard
因此,我正在使用GDK在Google Glass上發布實時卡,但是在發布新卡之后,我無法解決取消發布該卡的方法。 如果沒有,它會回到時鍾屏幕,看起來很糟糕。
這是我的liveCard Publishing,您可以選擇一個已經激活的卡並在以后將其刪除嗎? 我希望這是一個邏輯問題,但我無法完全解決。
public void makeNotificationCard() {
RemoteViews aRV = new RemoteViews(this.getPackageName(), R.layout.card_text);
mNotCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
aRV.setTextViewText(R.id.price, bigNum);
aRV.setTextViewText(R.id.price2, littleNum);
aRV.setTextViewText(R.id.merchant, shop);
mNotCard.setViews(aRV);
Intent mIntent = new Intent(this, MainActivity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
mNotCard.setAction(PendingIntent.getActivity(this, 0, mIntent, 0));
mNotCard.publish(LiveCard.PublishMode.REVEAL);
}
首先,從XE16開始,TimelineManager已被刪除。 所以代替:
mNotCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
您將需要使用
mNotCard = new LiveCard(context, LIVE_CARD_ID);
至於取消發布,我不確定是否完全了解您的問題,但您可以直接致電
mNotCard.unpublish();
這會將卡從時間軸中刪除。 如果您在創建新的LiveCard之前執行此操作,並使用LiveCard.PublishMode.REVEAL
發布新的LiveCard.PublishMode.REVEAL
則應該直接跳轉到該位置,我使用類似
public int onStartCommand(Intent intent, int flags, int startId) {
if (mLiveCard != null) {
mLiveCard.unpublish();
mLiveCard.publish(LiveCard.PublishMode.REVEAL);
return START_STICKY;
}
// other stuff to set up card if null
}
這將確保在觸發該命令時將焦點對准活動卡。
希望能有所幫助。 如果我錯過了要點,請告訴我,我會盡力澄清。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.