Android Wear Tile 仅适用于 TileUiClient

Android Wear Tile only works with TileUiClient

我正在尝试在 Java 中编写 Android Wear 磁贴。我使用 TileUiClient 完成了我的设计。 在 Activity 中预览 Tile 效果很好,但一旦我尝试正常查看该图块,它就不再显示任何内容。它只显示磁贴名称和图标。当我尝试在 Kotlin 中做同样的事情时,它工作正常。有人知道为什么会这样吗?

它应该是什么样子:

外观:

这是我的 Java 代码:

package com.example.wear.tiles;

import static androidx.wear.tiles.ColorBuilders.argb;
import static androidx.wear.tiles.DimensionBuilders.degrees;
import static androidx.wear.tiles.DimensionBuilders.dp;
import static androidx.wear.tiles.DimensionBuilders.expand;

import androidx.annotation.NonNull;
import androidx.wear.tiles.ActionBuilders;
import androidx.wear.tiles.DimensionBuilders;
import androidx.wear.tiles.LayoutElementBuilders;
import androidx.wear.tiles.ModifiersBuilders;
import androidx.wear.tiles.RequestBuilders;
import androidx.wear.tiles.ResourceBuilders;
import androidx.wear.tiles.TileBuilders;
import androidx.wear.tiles.TileService;
import androidx.wear.tiles.TimelineBuilders;

import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;


public class Tile extends TileService {
    private static final String RESOURCES_VERSION = "1";

    @NonNull
    @Override
    protected ListenableFuture<TileBuilders.Tile> onTileRequest(@NonNull RequestBuilders.TileRequest requestParams) {

        return Futures.immediateFuture(new TileBuilders.Tile.Builder()
                .setResourcesVersion(RESOURCES_VERSION)
                //.setFreshnessIntervalMillis(60*1000*5) // 60 minutes
                .setTimeline(new TimelineBuilders.Timeline.Builder()
                        .addTimelineEntry(new TimelineBuilders.TimelineEntry.Builder()
                            .setLayout(new LayoutElementBuilders.Layout.Builder()
                                    .setRoot(new LayoutElementBuilders.Text.Builder().setText("Test").setModifiers(new ModifiersBuilders.Modifiers.Builder().setSemantics(new ModifiersBuilders.Semantics.Builder().setContentDescription("lol").build()).build()
                                            ).build()
                                    ).build()
                            ).build()
                    ).build()
            ).build()
        );
    }

    @NonNull
    @Override
    protected ListenableFuture<ResourceBuilders.Resources> onResourcesRequest(@NonNull RequestBuilders.ResourcesRequest requestParams) {
        return Futures.immediateFuture(new ResourceBuilders.Resources.Builder()
                .setVersion("5")
                .build());
    }
}

我已经发现了我的错误,我在.setVersion("5")中的onResourcesRequest()和onTileRequest()中设置了两个不同的版本。我最初更改了它们,因为它似乎解决了另一个问题(我的图片未渲染)。 始终设置相同的版本号。