gpt4 book ai didi

android - Android Wear 自定义表盘

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:21:29 26 4
gpt4 key购买 nike

一些包含自定义表盘的 Android Wear 应用已经问世 (like this one)。它们不仅仅是显示表盘的应用程序;它们是成熟的面孔,长按 watch 的主屏幕时可选择。我找不到任何关于如何设置您的应用程序以提供自定义面孔的文档。您如何配置您的应用以提供人脸?

最佳答案

编辑 随着 Android Wear 更新到 Lollipop,Android Wear 表盘有一个全新的(更重要的是,官方)API。

您可以查看 blog post关于这个主题,请阅读 official documentationdownload the sample code .

此行以下的所有内容仅供历史引用:)


您只需提供一个具有特定 Intent 过滤器的 Activity,并包含一些权限(来自 here 的信息)。

Activity :

<activity
android:name=".WatchActivity"
android:allowEmbedded="true"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:label="@string/watch_preview_name">

<meta-data
android:name="com.google.android.clockwork.home.preview"
android:resource="@drawable/watch_preview_image" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.google.android.clockwork.home.category.HOME_BACKGROUND" />
</intent-filter>
</activity>

权限:

<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

顺便说一句,你提到的Play商店应用程序的源代码也是availabe on github .


包含 WAKE_LOCK 权限的原因在 this G+ post by Sam Duke 中有很好的解释。 .基本上,当 watch 变暗时,CPU 会进入低功耗状态,因此不会立即显示表盘显示的更新。每当屏幕需要更新时获取 PARTIAL_WAKE_LOCK 即可解决此问题。


编辑 请注意,这是一个“非官方”API,根据this post by Wayne Piekarski ,它可能会在未来发布官方 API 时中断(这应该会在 Android Wear 升级到 L 时发生)。

关于android - Android Wear 自定义表盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24623321/

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